Page 1 of 1

PHPSent to Email Code Problem

Posted: Sat Dec 06, 2008 9:22 pm
by azylka
I'm trying to create an equivalent of Gmail or Yahoo! on my server. I have a registration.html page with this code:

Code: Select all

<form method="POST" action="default.php"> 
            <br>* = Required<br><br> 
   &nbsp; &nbsp; &nbsp;*Name: <input type="text" name="Name:" size="23"><br> 
   <br> 
   &nbsp; &nbsp; &nbsp;*Email: <input type="text" name="Email:" size="24"><br> 
   <br> 
   &nbsp; &nbsp; &nbsp;*User Name: <input type="text" name="User Name:" size="19"><br> 
   <br> 
     &nbsp; &nbsp; &nbsp;*Password: <input type="password" name"Password:" size="20"><br> 
     <br> 
     &nbsp; &nbsp; &nbsp;*Confirm: <input type="password" name="Confirm Password:" size="22"> 
     <br> 
   <br> 
   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <input type="submit" value="Submit" name="submit"> 
</form>

and default.php with this:

Code: Select all

<center><h1><?php
if(isset($_POST['submit'])) {
$to = "me@email.com";
$subject = "Registration Request";
$name_field = $_POST['Name:'];
$email_field = $_POST['Email:'];
$username = $_POST['[color=#FF0000]User Name:[/color]'];
$password = $_POST['[color=#FF0000]Password:[/color]'];
$confirm = $_POST['[color=#FF0000]Confirm Password:[/color]'];
 
$body = "Name: $name_field\n E-Mail: $email_field\n User Name: $username\n Password: $password\n Confirm Password: $confirm\n";
 
echo "Your details were submitted. Please check your inbox within 24 hours for more instructions.";
mail($to, $subject, $body);
} else {
echo "Your details were not submitted, please try again.";
}
?>
</h1></center>
When I tested this method out, the "User Name:", "Password:", and "Confirm Password" as highlighted above in red didn't get sent to me. Can anyone help?

Re: PHPSent to Email Code Problem

Posted: Sat Dec 06, 2008 10:01 pm
by requinix
I bet the spaces have something to do with it.

Use reasonable names for your form fields, not something that looks nice or pretty. "name", "email", "username", "password", and "confirm" are some good examples.