Page 1 of 1

Please Help!!My srcipt Keeps Timing out!!

Posted: Thu Apr 17, 2003 4:15 am
by gasoga
Hi! I am trying to regiser users to my site and randomly generate passwords and automatically email the info to them!
THe users details do get inserted into thw database but it won't email the info to the user and the page just then times out!!
Am really stuck any help would be really appreciated!!!

Here is the code!!<?PHP

include('function.php');
//extract($_REQUEST);

$db = odbc_connect($dbsource, $dbuser, $dbpass) or die("Couldn't Connect to DB");


$UserName = $_POST['UserName'];
$FirstName = $_POST['FirstName'];
$LastName = $_POST['LastName'];
$Email = $_POST['Email'];

$UserName = stripslashes($UserName);
$FirstName = stripslashes($FirstName);
$LastName = stripslashes($LastName);
$Email = stripslashes($Email);



if(($UserName == '') || ($FirstName == '' ) || ($LastName == '' ) || ($Email == '') )
{
echo ("<strong><font color = red>You did not submit the following required information! </strong>");

if($UserName == '')
{
echo ("<strong><font color = red>Desired Username</strong></font>is a required field.</strong>");
}
if($FirstName == '' )
{
echo ("<strong><font color = red>First Name</strong></font>is a required field. </strong>");
}
if($LastName == '' )
{
echo ("<strong><font color = red>Last Name </strong></font>is a required field. </strong>");
}
if($Email == '')
{
echo ("<strong><font color = red>Email Address</strong></font>is a required field.</strong>");
}


echo("<br>");
echo("<br>");
echo("<br>");
echo("<strong><a href ='register.php'>Please go back and fill in the above information</strong></a>");
exit(); // if the error checking has failed, we'll exit the script!
}


$Q01 = "SELECT *
FROM $dbtable
WHERE UserName = '$UserName'";
$R01 = odbc_exec($db,$Q01) or die("Bad Q01:".mysql_error());
$A01 = odbc_fetch_into($R01, $A11);



if($A01 != 0)
{
echo( "That UserName Already Exists, Please Chose Another!");
//@header("Location: //register.php?ErrorCode=$ErrorCode&FirstName=$FirstName&LastName=$LastName&UnitNumber=$UnitNumber&Email=$Email&WebSite=$WebSi//te");
exit;
}

$Q02 = "SELECT *
FROM $dbtable
WHERE Email = '$Email'";
$R02 = odbc_exec($db,$Q02) or die("Bad Q01:".mysql_error());
$A02 = odbc_fetch_into($R02, $A12);

if($A02 != 0)
{
echo( "That Email Is Already Reistered!");
exit;
}






$random_password = makeRandomPassword();
$db_password = md5($random_password);

$Q03 = "INSERT INTO $dbtable VALUES ('',0,'$UserName', '$FirstName', '$LastName','$db_password', '$Email')";
$R03 = odbc_exec($db,$Q03) or die("BadQ03");
// $A03 = odbc_fetch_into($R03, $A13);

if(!$Q03)
{
echo 'There has been an error creating your account. Please contact the webmaster.';
exit;
}
else {
//$userid = odbc_insert_id();
// Let's mail the user!
$subject = "Your Membership at Deft Consulting HelpDesk!";
$message = "Dear $first_name $last_name,Thank you for registering at our website You are two steps away from logging in and accessing our exclusive member To activate your membership, please click here: http://supportt.ie/activ$/activate.php? ... b_password Once you activate your membership, you will be able to login withn the following information Username: $username Password: $random_password Thanks! The Webmaster This is an automated response, please do not reply!";
$mailheaders = "From:";
mail($Email, $subject, $message, $mailheaders);
echo 'Your membership information has been mailed to your email address! Please check it and follow the directions!';

}




?>

Posted: Thu Apr 17, 2003 7:57 am
by Wayne
are you sure the server is configured to send mail?

Posted: Fri Apr 18, 2003 4:29 am
by gasoga
Ooops!! Yep that was the problem!!!!
Needed to connect to the smtp server!!!
Thanx!!!! :)