Need help tweaking my php contact form
Posted: Sun 26. Sep 2004, 00:17
Hi,
I need help tweaking my php contact form. The form works fine, but there are two issues:
1. It seems the form will only send the message when the sender's email is a valid address. Is there a way to make the form also work when the email may be invalid?
2. Also, when the message is sent, I cannot see the "Name" of the sender anywhere. I would like to have the name appear in the body of the message. How can I accomplish this?
I would really appreciate some help with this.
The form and php are noted below:
Contact Form:
<form method="post" action="sendmail.php">
Name: <input name="name" type="text" /><br /><br />
Email: <input name="email" type="text" /><br /><br />
Message:<br />
<textarea name="message" rows="5" cols="25">
</textarea><br />
<input type="submit" value="Send" />
</form>
PHP Script:
<?
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
mail( "myemail@address.com", "Message from BSH Website",
$message, "From: $email" );
header( "Location: http://www.example.com/index.htm" );
?>
Th[advance]anks to anyone who helps,
Mark
P.S. I don't have much experience with PHP, so any other comments or suggestions about my contact form are also appreciated.
I need help tweaking my php contact form. The form works fine, but there are two issues:
1. It seems the form will only send the message when the sender's email is a valid address. Is there a way to make the form also work when the email may be invalid?
2. Also, when the message is sent, I cannot see the "Name" of the sender anywhere. I would like to have the name appear in the body of the message. How can I accomplish this?
I would really appreciate some help with this.
The form and php are noted below:
Contact Form:
<form method="post" action="sendmail.php">
Name: <input name="name" type="text" /><br /><br />
Email: <input name="email" type="text" /><br /><br />
Message:<br />
<textarea name="message" rows="5" cols="25">
</textarea><br />
<input type="submit" value="Send" />
</form>
PHP Script:
<?
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
mail( "myemail@address.com", "Message from BSH Website",
$message, "From: $email" );
header( "Location: http://www.example.com/index.htm" );
?>
Th[advance]anks to anyone who helps,
Mark
P.S. I don't have much experience with PHP, so any other comments or suggestions about my contact form are also appreciated.