Wednesday, May 22, 2013
   
Text Size

Our Web Design Logo

Vote for this web design blog | Just click on vote for me

Web Design ********** Top Blogs

b11. How To Create a PHP Action Form Feedback Script For Your Html Contact Us Form

Web Design Tools and Tips

article 11/11

//// These brackets refer to the explanation and are not part of the script ////

Part 1 ( The php action feedback script ) <?php
1 $mailto = ' This e-mail address is being protected from spambots. You need JavaScript enabled to view it . ' ;
//// The email used here will be the email that you created on your hosting server ////
2 $subject = " Blog Form Results" ;
//// This will be the subject of your email when you login to your hosting email account ////
3 $formurl = " topwebdesign/blog.html " ;
//// This will be the url of where your html form is located ////


4 $errorurl = " topwebdesign.ie/error.html " ;
//// This will be the error page that will appear if the necessary required fields are not properly filled out.You must create this page yourself ////
5 $thankyouurl = " topwebdesign.ie/thanks-blog.html " ;
//// This will be the page that appears once all the required fields have been properly filled out.You must create this page yourself ////

6 $email_is_required = 1 ; //// The six lines here you can leave as they are and remember that the two required fields ie email and name are defined here ////
7 $name_is_required = 1 ;
8 $uself = 0 ;
9 $use_envsender = 0 ;
10 $use_webmaster_email_for_from = 1 ;
11 $use_utf8 = 1 ;

// -------------------- END OF CONFIGURABLE SECTION ---------------//

( All of the rest of the script can be left as it is but for an explanation of key individual items look at the description within the brackets //// //// )

12 $headersep = ( !isset ( $uself ) || ($uself == 0 )) ? " \r\n " : " \n " ;
13 $content_type = ( !isset ( $use_utf8 ) || ($use_utf8 == 0 )) ? ' Content-Type: text/plain ; charset=" iso-8859-1"' : ' Content-Type: text/plain ; charset=" utf-8 "' ;
14 if ( !isset ( $use_envsender )) { $use_envsender = 0 ; }
15 $envsender = "-f$mailto" ;
16 $name = $_POST [ ' name ' ] ;
//// The name in brackets [ 'name' ] refers to the html form code ie <input name="name" type="text" id="name" size="25" maxlength="40">.The keywords here as far as the php script is concerned are <input name="name" because this line enables the php script to catch the information inserted into the name textfield ////
17 $email = $_POST [ ' email ' ] ;
//// The same applies to email [ 'email' ] as far as the html form code is concerned <input name="email" type="text" id="email"size="30" maxlength="40" > .The keywords here,as in the above,as far as the php script is concerned are <input name="email" because this enables it to catch the information inserted into the email textfield ////
18 $comments = $_POST [ ' comments' ] ;
//// As above ////
19 $http_referrer = getenv ( "HTTP_REFERER" ) ;

if ( !isset ($_POST [ ' email ' ] )) {
header ( " Location: $formurl " ) ;
exit ;
}
if (($email_is_required && (empty ($email) || !ereg ( "@ ", $email ))) || ($name_is_required && empty ($name))) {
header ( " Location: $errorurl " ) ;
exit ;
}
if ( ereg ( " [ \r\n ] " , $name ) || ereg ( " [ \r\n ] " , $email ) ) {
header ( " Location: $errorurl " ) ;
exit ;
}
if ( empty ( $email )) {
$email = $mailto ;
}
$fromemail = ( !isset ( $use_webmaster_email_for_from ) || ($use_webmaster_email_for_from == 0 )) ? $email : $mailto ;

if ( get_magic_quotes_gpc ()) {
$comments = stripslashes ( $comments ) ;

}

20 $messageproper =
" This message was sent from : \n " .
" $http_referrer\n " .
"------------------------------------------------------------\n" .
" Name of sender : $name\n " .
//// This is what you see within your hosting email account when you check your email ie name of sender : joe blogs ////
" Email of sender : $email\n " .
//// You will also see the email of sender within your email hosting account ie email of sender : This e-mail address is being protected from spambots. You need JavaScript enabled to view it ////


"------------------------- COMMENTS -------------------------\n\n" .
//// This above line inserts a comments section within your hosting email account ////
$comments .
//// This line shows the comments made within the email message ////

"\n\n------------------------------------------------------------\n" ;

$headers =
"From: \"$name\" <$fromemail>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer : chfeedback.php 2.13.0" .
//// The above line refers to the original script and must be left intact ////
$headersep . ' MIME-Version: 1.0' . $headersep . $content_type ;

if ($use_envsender) {
mail ($mailto, $subject, $messageproper, $headers, $envsender ) ;
//// The above line is the mail function and it gathers all the information for you within your hosting email account ////
}
else {
mail ($mailto, $subject, $messageproper, $headers ) ;
}
header ( "Location: $thankyouurl" ) ;
exit ;

?>

Thats the php script completed so just file and save this script as feedback.php.You then need to upload this script in ascii mode to the root directory of your website or in other words where all your other html files are located.

Part 2 ( The html form code ) //// The keywords in the html form code are name = " name ", name = " email ", name = " comments ".The words in brackets refer to the words that you used to define your php variables ie [ ' name ' ], [ ' email ' ], [ ' comments ' ] and these words must be the same in order for the php script to collect the information submitted within the html form ////
The html code of your form will look like the following :


<form action="feedback.php" method="post">


<table width="60%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#D8D8D8" summary = "feedback form">
<tr>
<td width="27%"><div align="left"><strong><label for="name">Name</label></strong> <em>required</em></div></td>
<td width="73%">
<div align="left">
<input name="name" type="text" id="name" size="25" maxlength="40">
</div> </td>
</tr>
<tr>
<td><div align="left"><strong><label for="email">Email</label></strong><span><em> required</em></span></div></td>
<td>
<div align="left">
<input name="email" type="text" id="email"size="30" maxlength="40" >
</div> </td>
</tr>
<tr>

<td><div align="left"><strong><label for="comments">Comments</label></strong></div></td>
<td>
<div align="left">
<textarea name="comments" cols="30" rows="3" id="comments"></textarea>
</div> </td>
</tr>
<tr>
<td> </td>
<td><label>

<div align="left">
<input type="submit" name="submit" id="submit" value="Submit" />
<input type="reset" name="Reset" id="Reset" value="Reset" />
//// The above two lines have nothing to do with the php script but are necessary html form attributes ////
</div>
</label></td>
</tr>
</table>
</form>

Thats it, your finished.

Web Design - Search Engines

Just click on the image to get the web design facts about the main search engines market share for Europe.

An image of a graph
Search Engines Market Share

Web Design - Flash Example

Web Design - Flash Advert Example

Web Design Address

top web design
Business registration no. 359901,
Registered offices : 192 Shanowen Rd, Santry, Dublin 9,
Republic of Ireland
Phone no top web design | Irish flag | Web Design Ireland . +353 1 8423192
Mobile no top web design | Irish flag | Web Design Ireland . +353 ( 0 ) 86 3625537


Contact Us

Web Design Tools and Tips Articles

b13. How To Use the Random Image Module Within Your Joomla Content Management System

article 13/13

1.The first step in inserting random images into your Joomla website is to upload the relevant graphics ie PNG,GIF AND JPEGS ( JPEGS are the default images for the random image module ),so to keep it simple upload a JPEG because this images type is automatically filled in for you within the Joomla random image module ( MODULE PARAMETERS : image type = jpg )

Read more... Link