Hello,
I am trying to learn php and I am having some problems with the mail. i am using Linux and I am trying to send an email after the person fills out a little form and pushes submit then emails them, passoword and user name. When I try to test it I get the successful message then I never recieve the email. here Is my PHP code:
<?php # Script 3.11 - register.php
$page_title = 'Register!';
include ('header.inc');
if (isset($_POST['submit'])) {
if (strlen($_POST['name']) > 0) {
$name = TRUE;
} else {
$name = FALSE;
echo '<p>You forgot to enter your name!';
}
if (strlen($_POST['email']) > 0) {
$email = TRUE;
} else {
$email = FALSE;
echo '<p>You forgot to enter your email address!';
}
if (strlen($_POST['username']) > 0) {
$username = TRUE;
} else {
$username = FALSE;
echo '<p>You forgot to enter your user name!';
}
if (strlen($_POST['password1']) > 0)
{
if ($_POST['password1'] == $_POST['password2']) {
$password = TRUE;
} else {
$password = FALSE;
echo '<p>Your password did not match the confirmed password!';
}
} else {
$password = FALSE;
echo '<p>You fogot to enter your password!';
}
if ($name && $email && $username && $password) {
$body = "thank You for gegistering with our site!\nYour username is '{$_POST['username']}' and your password is '{$_POST['password1']}'.\n\nSincerely,\nUs";
mail ($_POST['email'], 'Thank You for registering!', $body, 'From: [email]abranaugh@gmail.com[/email]');
echo '<p>You are now registered with our site! An email has been sent to your email address confirming the information';
} else {
echo '<p>Please go back and try again.';
}
} else {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset><legend>Enter your information in the form below</legend>
<P><B>Name:</b> <input type="text" name="name" size="20" maxlength="40">
<p><b>Email Address:</b><input type="text" name="email" size="20" maxlength="60">
<p><b>User Name:</b><input type="text" name="username" size="20" maxlength="20">
<p><b>Passowrd:</b><input type="password" name="password1" size="20" maxlength="15">
<p><b>Confirm Password</b><input type="password" name="password2" size="20" naxlength="15">
</fieldset>
<div align="center"><input type="submit" name="submit" value="Submit Information"></div>
</form>
<?php
} //End of the main SUBMIT conditional.
include ('footer.inc');
?>
Thank You for you help.