dinku33
01-21-2008, 06:15 PM
Can anybody help me for the code below ?
I have html codes for Mailform as below. I want to make php code to support this html form. I have posted the php form but it is not proper. Can anybody help me ?
<form action="feedback.php" method="post">
<table border="0" cellpadding="8" cellspacing="8" summary="feedback form">
<tr><td>Property name:</td><td><input type="text" name="propertyname" size="25" /></td></tr>
<tr><td>Number of rooms:</td><td><input type="text" name="numberofrooms" size="25" /></td></tr>
<tr><td>Star rating:</td><td><input type="text" name="starrating" size="25" /></td></tr>
<tr><td colspan="2">Address<br />
<textarea rows="15" cols="45" name="comments"></textarea></td></tr>
<tr><td>Phone number:</td><td><input type="text" name="phonenumber" size="25" /></td></tr>
<tr><td>Fax number:</td><td><input type="text" name="faxnumber" size="25" /></td></tr>
<tr><td>Email address:</td><td><input type="text" name="email" size="25" /></td></tr>
<tr><td>Website:</td><td><input type="text" name="website" size="25" /></td></tr>
<tr>
<td align="center" colspan="2">
<input type="submit" value="Add your hotel" /><br />
</td>
</tr>
</table>
</form>
<?php
// ------------- CONFIGURABLE SECTION ------------------------
// $mailto - set to the email address you want the form
// sent to, eg
//$mailto = "youremailaddress@example.com" ;
$mailto = 'youremailaddress@example.com' ;
// $subject - set to the Subject line of the email, eg
//$subject = "Feedback Form" ;
$subject = "Feedback Form" ;
// the pages to be displayed, eg
//$formurl = "http://www.example.com/feedback.html" ;
//$errorurl = "http://www.example.com/error.html" ;
//$thankyouurl = "http://www.example.com/thankyou.html" ;
$formurl = "http://your-feed-back.htm" ;
$errorurl = "http://error.htm" ;
$thankyouurl = "http://thank-you.htm" ;
$uself = 1;
// -------------------- END OF CONFIGURABLE SECTION ---------------
$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );
if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name) || empty($email) || empty($comments)) {
header( "Location: $errorurl" );
exit ;
}
if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
header( "Location: $errorurl" );
exit ;
}
if (get_magic_quotes_gpc()) {
$comments = stripslashes( $comments );
}
$messageproper =
"This message was sent from:\n" .
"$http_referrer\n" .
"------------------------------------------------------------\n" .
"Name of sender: $name\n" .
"Email of sender: $email\n" .
"------------------------- COMMENTS -------------------------\n\n" .
$comments .
"\n\n------------------------------------------------------------\n" ;
mail($mailto, $subject, $messageproper,
"From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.08" );
header( "Location: $thankyouurl" );
exit ;
?>
I have html codes for Mailform as below. I want to make php code to support this html form. I have posted the php form but it is not proper. Can anybody help me ?
<form action="feedback.php" method="post">
<table border="0" cellpadding="8" cellspacing="8" summary="feedback form">
<tr><td>Property name:</td><td><input type="text" name="propertyname" size="25" /></td></tr>
<tr><td>Number of rooms:</td><td><input type="text" name="numberofrooms" size="25" /></td></tr>
<tr><td>Star rating:</td><td><input type="text" name="starrating" size="25" /></td></tr>
<tr><td colspan="2">Address<br />
<textarea rows="15" cols="45" name="comments"></textarea></td></tr>
<tr><td>Phone number:</td><td><input type="text" name="phonenumber" size="25" /></td></tr>
<tr><td>Fax number:</td><td><input type="text" name="faxnumber" size="25" /></td></tr>
<tr><td>Email address:</td><td><input type="text" name="email" size="25" /></td></tr>
<tr><td>Website:</td><td><input type="text" name="website" size="25" /></td></tr>
<tr>
<td align="center" colspan="2">
<input type="submit" value="Add your hotel" /><br />
</td>
</tr>
</table>
</form>
<?php
// ------------- CONFIGURABLE SECTION ------------------------
// $mailto - set to the email address you want the form
// sent to, eg
//$mailto = "youremailaddress@example.com" ;
$mailto = 'youremailaddress@example.com' ;
// $subject - set to the Subject line of the email, eg
//$subject = "Feedback Form" ;
$subject = "Feedback Form" ;
// the pages to be displayed, eg
//$formurl = "http://www.example.com/feedback.html" ;
//$errorurl = "http://www.example.com/error.html" ;
//$thankyouurl = "http://www.example.com/thankyou.html" ;
$formurl = "http://your-feed-back.htm" ;
$errorurl = "http://error.htm" ;
$thankyouurl = "http://thank-you.htm" ;
$uself = 1;
// -------------------- END OF CONFIGURABLE SECTION ---------------
$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );
if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name) || empty($email) || empty($comments)) {
header( "Location: $errorurl" );
exit ;
}
if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
header( "Location: $errorurl" );
exit ;
}
if (get_magic_quotes_gpc()) {
$comments = stripslashes( $comments );
}
$messageproper =
"This message was sent from:\n" .
"$http_referrer\n" .
"------------------------------------------------------------\n" .
"Name of sender: $name\n" .
"Email of sender: $email\n" .
"------------------------- COMMENTS -------------------------\n\n" .
$comments .
"\n\n------------------------------------------------------------\n" ;
mail($mailto, $subject, $messageproper,
"From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.08" );
header( "Location: $thankyouurl" );
exit ;
?>