Page 1 of 1

Need help tweaking my php contact form

Posted: Sun 26. Sep 2004, 00:17
by Operator
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.

more info

Posted: Sun 26. Sep 2004, 00:23
by Operator
I forgot to mention this contact form is not for my current phpWCMS project.
It is for a site made with html and css.

Posted: Sun 26. Sep 2004, 01:03
by brans
hmm I really don't see any reason why you can't enter any invalid email adress...


Code: Select all

<?
$name = $_REQUEST['name'] ;

$email = $name."<";
$email .= $_REQUEST['email'] ;
$email .= ">";

$message = "From:".$name."/n Message: /n";
$message .= $_REQUEST['message'] ;

mail( "myemail@address.com", "Message from BSH Website",
$message, "From: $email" );
header( "Location: http://www.example.com/index.htm" );
?> 
try this to have the name displayed in the

thanks

Posted: Tue 28. Sep 2004, 02:48
by Operator
Hi,
I've figured it out. THanks anyway