Showing posts with label Web. Show all posts
Showing posts with label Web. Show all posts

Thursday, October 15, 2009

HTML Form elements array

Creating array of HTML form elements

Array is a collection of similar data elements, means we can use array to store similar elements referenced under a common name.


In web development sometimes we need to group HTML form elements as arrays do. For example, you have a form where user has to select his hobbies from a group of check boxes as given below.










Sample Code
<form action="showlist.php" method="post" name="hobby_frm">
<h3> Select your hobbies </h3>
<input type="checkbox" name="hobbies[]" value="hb1"  />
Reading <br />
<input type="checkbox" name="hobbies[]" value="hb2" />
Surfing <br />
<input type="checkbox" name="hobbies[]" value="hb3" />
Listening to music  <br />
<input type="submit" value="submit" />
</form>
Please notice the name of all checkboxes hobbies[]
The above code will define an array with the name hobbies

Accessing form elements array using JavaScript

Now, let's see how to access the hobbies[] using JavaScript.
<script type="text/javascript">
var hobbies = document.hobby_frm.elements['hobbies[]'];
var str = "Length  : "+hobbies.length+"\n";
for( var i = 0; i < hobbies.length; i++ ) {
str = str + "Hobby "+(i+1)+" : "+hobbies[i].value+"\n";
}
alert(str);
</script>
Handle form elements array in PHP

In PHP, data sent from a form with post method is available in $_POST array.
We can access hobbies[] using the following code.


<?php
$hobbies = $_POST['hobbies']; // use name of the array as key
foreach( $hobbies as $value )
print $value;
?>



courtesey webdevelopment hosting company cochin kerala

Wednesday, July 15, 2009

The Blogger Data API

What is the Blogger Data API?

The Blogger Data API allows client applications to view and update Blogger content in the form of Google Data API feeds. Your client application can use the Data API to create new blog posts, edit or delete existing posts, and query for posts that match particular criteria.



follow the link
http://code.google.com/apis/blogger/

by, kerala webhosting

Saturday, April 25, 2009

Send email from a PHP script

PHPMailer is a powerful email transport class. Sending email using PHPMailer is simple.

PHPMailer features:-


  • Supports emails digitally signed with S/MIME encryption!
  • Supports emails with multiple TOs, CCs, BCCs and REPLY-TOs
  • Works on any platform.
  • Supports Text & HTML emails.
  • Embedded image support.
  • Multipart/alternative emails for mail clients that do not read HTML email.
  • Flexible debugging.
  • Custom mail headers.
  • Redundant SMTP servers.
  • Support for 8bit, base64, binary, and quoted-printable encoding.
  • Word wrap.
  • Multiple fs, string, and binary attachments (those from database, string, etc).
  • SMTP authentication.
  • Tested on multiple SMTP servers: Sendmail, qmail, Postfix, Gmail, Imail, Exchange, etc.
  • Good documentation, many examples included in download.
  • It's swift, small, and simple.
[http://phpmailer.codeworxtech.com]

How to use

Download PHPMailer from http://sourceforge.net/projects/PHPmailer
Extract it into your web directory.
Turn on SSL support.
Use the following code to send email.

Sample code

include("/lib/phpmailer/class.phpmailer.php");
$mail = new PHPMailer(); // Creating PHPMailer object
$body = "Hai hello, this is my first mail using PHPMailer. ";
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = "ssl://smtp.gmail.com:465"; // SMTP Server.
/*
Setting gmail as the SMTP Server
*/
$mail->Username = "myphpapp@gmail.com"; // username [Gmail]
$mail->Password = "mypassword
"; // password for myphpapp
$mail->AltBody = "This is the body when user views in plain text format";
$mail->Subject = "Say hello!"; // This is the subject
$mail->From = "myphpapp@gmail.com"; // From email-id
$mail->FromName = "PHP Developer"; // From Name
$mail->MsgHTML($body);
$mail->AddAddress("toaddress@gmail.com","Name"); // To address.
$mail->IsHTML(true);
if(!
$mail->Send()) {
echo
"Mailer Error: " . $mail->ErrorInfo;
}
else {
echo
"Message has been sent";
}
?> 


courtsey: nexabion software cum webdevelopers and webhosting providers kerala

Tuesday, March 24, 2009

Creating HTML link button

Simple html code to create link button


<input value="Click Me" type="button" onclick="window.location.href='http://codeglobe.blogspot.com'; " >

from, nexabion webhosting kerala cochin

LinkWithin

Related Posts with Thumbnails