PDA

View Full Version : Help with simple form please...


sparked84
08-19-2009, 12:46 AM
Hello,

I have been able to make a simple contact form work in the past... but now I'm trying to do the following:

The form contains name, email and telephone. I'd like it to send from the form email but contain all three of those in the message body.

FORM:

<form name="form1" method="post" action="sendmail.php">
<label><span class="style13">Register As My Guest: </span><span class="style14"><br>
<br>
Name: </span> <br>
<input type="textfield" name="name">
</label>
<br>
<label><span class="style14">Email: <br>
</span>
<input type="textfield" name="email">
</label>
<br>
<label class="style14">Telephone: <br>
<input type="textfield" name="telephone">
<br>
</label>
<label>
<input name="Submit2" type="submit" class="style14" value="Submit">
</label>
<br>
<label></label>
</form>


PHP:

<?php
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$telephone = $_REQUEST['telephone'] ;

mail( "info@mysite.net", "New Guest Registration!",
$name, $email, $telephone, "From: $email" );
header( "Location: http://www.mysite.net/thankyouregistered.html" );
?>


Any help is greatly appreciated :)

edbr
08-19-2009, 12:52 AM
$name = $_REQUEST['name']
should be
$name = $_POST['name'] as the form is sending post values

sparked84
08-20-2009, 05:34 PM
That did not appear to work... it sends fine with "REQUEST" I just can't get it to send all the parts in the message area. I'd like it to send an email as follows:

from: $email

Message body:

$name
$email
$telephone

edbr
08-21-2009, 01:17 AM
ok but i cant see why you would use it . $_REQUEST

sparked84
08-21-2009, 01:21 AM
Because it works and using "POST" does not. It doesn't do anything with I change it to POST...

edbr
08-21-2009, 01:40 AM
ok but i dont see any benefit from using request as it is used to collect $_POST and $_GET values, and can , i believe give problems as it collects cookies and could give security assues. howeve no matter. try this ( i change to POST but use what you want)

$name = $_POST['name'] ;
$email = $_POST['email'] ;
$telephone = $_POST['telephone'] ;
$subject="New Guest Registration!";
$mail="info@mysite.net";
$message="From: $email \n
name : $name \n
Telephone : $telephone
" ;


$email, $telephone,
mail( $mail,$subject,$message);
header( "Location: http://www.mysite.net/thankyouregistered.html" );