Hi All!
I've got a strange problem that I'm hoping someone can help me with. I've got a sign up script that allows a user to enter their particulars...it then sends that information to my member database, and sends the user in question an email with further instructions...Everything works like a charm, except the email sending...I would really appreciate it if someone could glance over my code and offer a suggestion as to why the mail() function would be returning successful, but the email never lands...I'm about 100% sure it's in the coding here, but I just can't find the problem.
Thanks!!
<?php
require_once('scripts/connect.php');
require_once('scripts/validation.php');
error_reporting(E_ALL);
$error_msg="";
if (isset($_POST['submit']))
{
//Post Variables: Stripped of all dangerous characters.
$Name=mysql_real_escape_string($_POST['sName']);
$Email=mysql_real_escape_string($_POST['uEmail']);
$UserName=mysql_real_escape_string($_POST['uName']);
$Password=mysql_real_escape_string($_POST['uPass']);
//Input Validation : We've got to make sure they put something in each box.
$is_name=CheckEmpty($Name);
$is_email=CheckEmpty($Email);
$is_user=CheckEmpty($UserName);
$is_pass=CheckEmpty($Password);
if (!$is_name||!$is_email||!$is_user||!$is_pass)
{
$error_msg="<span style='font-color:red; font-weight:bold;'>Please fill out all fields before submitting your registration.</span>";
}
else
{
//No Duplicate UserNames : We've got to connect to the database and make sure that the user name they have selected is not the same as
//any other username in the database.
$verify_sql="SELECT * FROM tbl_users WHERE UserName='$uName'";
$result=mysql_query($verify_sql);
if (mysql_num_rows($result)!=0)
{
$error_msg="<span style='font-color:red; font-weight:bold;'>That User Name is already taken. Please enter another one.</span>";
}
else //If we're okay, then we need to both add the user to the database *and* send them the email that will allow them to
//confirm their account.
{
//Create confirmation hash : MD5 the password
$confirm_hash=md5($uPass);
//Send Email
//Email Headers
//$headers = 'MIME-Version: 1.0' . "\r\n";
//$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
//$headers .= 'From: admin@my-linkpage.com'. "\r\n";
//Email address to send the message to:
$EmailTo=$Email;
//The Subject Line of the email
$Subject="Sign Up Details for My-LinkPage.com";
//Our Message is equal to our content post.
$Message="A Message<br />";
//$Success = mail ($EmailTo,$Subject,$Message,$headers);
$Success = mail ($EmailTo,$Subject,$Message);
if ($Success==true)
{
header("Location: http://www.thoughtsandrambles.com/contact/thankyou.php");
}
else
{
header("Location: http://www.thoughtsandrambles.com/contact/messagefailed.php");
}
//Post to Database.
//$post_SQL="INSERT INTO tbl_users (UserName,UserPass,UserNick,UserEmail,UserCode) VALUES ('$UserName','$Password','$Name','$Email','$confirm_hash')";
$post_success=1;//mysql_query($post_SQL);
if ($post_success)
{
//If everything is posted correctly, we send them to the Thank You page.
echo "Normally going to thank you page.";
echo "$EmailTo<br />$Subject<br />$Message<br />$headers<br />";
}
else
{
//Will go to failure page after we've tested
echo ("Could not add to the database<br />".mysql_error());
}
}
}
}//End ISSet Submit
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="styles/lenderhomepage.css" media="screen" />
<title>Personal Link Page - Login</title>
</head>
<body>
<div id="pagewrap" style="width:800px; height:600px;">
<h2>Sign Up For An Account</h2>
<p align="left">
Fill out the form below to register for a My-Linkpage.com account. Once
you've completed the sign-up process, you can start creating your own
links page. Please note that we require your email in order for you to
verify your identity and complete the sign up process, and your email
will not be used for any other purpose. For more information, please
view our <a href="http://www.my-linkpage.com/documents/tos.html">terms of service</a>.
</p>
<p><?php echo ($error_msg); ?></p>
<div style="margin-left:auto; margin-right:auto; text-align:center;">
<form name="sign-up" method="post" action="#">
<table>
<tr><td align="right">Your Name:</td><td><input type="text" name="sName" size="40" /></td></tr>
<tr><td align="right">Your Email:</td><td><input type="text" name="uEmail" size="40" /></td></tr>
<tr><td align="right">Select A UserName:</td><td><input type="text" name="uName" size="40" /></td></tr>
<tr><td align="right">Select A Password:</td><td><input type="password" name="uPass" size="40" /></td></tr>
<tr><td align="center" colspan="2"><input type="submit" name="submit" value="Register Now" /></td></tr>
</table>
</form>
</div>
</div>
</body>
</html>
I'm aware that some of the email headers and the database code are commented out...in the final version of course, they would be active lines of code.
Thanks!!