Need help tweaking my php contact form

Post non-phpwcms related topics here - but I don't want to see "hey check this or that other cms". Post if you have a point or worthwhile comment, don't post just to increase you post count!
Post Reply
Operator
Posts: 25
Joined: Mon 6. Sep 2004, 21:55
Location: St. John's Newfoundland CA

Need help tweaking my php contact form

Post 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.
Operator
Posts: 25
Joined: Mon 6. Sep 2004, 21:55
Location: St. John's Newfoundland CA

more info

Post 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.
brans

Post 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
Operator
Posts: 25
Joined: Mon 6. Sep 2004, 21:55
Location: St. John's Newfoundland CA

thanks

Post by Operator »

Hi,
I've figured it out. THanks anyway
Post Reply