PHPSent to Email Code Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
azylka
Forum Commoner
Posts: 40
Joined: Sat Dec 06, 2008 9:11 pm

PHPSent to Email Code Problem

Post 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?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: PHPSent to Email Code Problem

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