interpim Posted March 12, 2007 Share Posted March 12, 2007 I created a registration script, and had it working fine... I wanted to add a email verification to this, basically creating a random code, emailing it, and having the user input this random code before the account could be validated... Well, now the script outputs nothing I've checked the random script code, and it works here is a link of just the random code generator function in action http://interpim.com/ambassade/testfunction.php the registration code is <?php include('config.php'); include('includes/functions.php'); $user=$_POST['username']; $pword=$_POST['password']; $pword2=$_POST['password2']; $email=$_POST['email']; if (empty($user) || empty($pword) || empty($email)) { header("Location: register.php?err=1"); exit(); } mysql_connect($server,$username,$password); @mysql_select_db($database) or die("unable to select database"); $query="SELECT * FROM main WHERE user_name='$user'"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); if ($num!=0) { echo "That username has already been taken, please try again<br> <a href='register.php'>Register</a>"; } elseif ($pword!=$pword2) { echo "The supplied passwords you gave do not match<br><a href='register.php'>Try Again</a><br>"; exit(); } mysql_connect($server,$username,$password); @mysql_select_db($database) or die("unable to select database"); $af=0; $query = "INSERT INTO main VALUES('','$user','$pword','','','','','','','','','','','','$af','','$code','','','','','','','$email','','','')"; mysql_query($query); mysql_close(); setcookie("user","$user"); setcookie("loggedin","true",time()+(86400*5)); $code=code_gen(); $reg_sub="Ambassade Game Registration confirmation email"; $reg_body="Thank you for registering for Ambassade... before you can log in, you must confirm your email by entering the following code on our website./n/n/n/n$code/n/n/n/n Thank you again,/n/nTeam Ambassade."; mail($email,$reg_sub,$reg_body); echo "Thank you for registering... you will shortly receive an email with a confirmation code<br>"; echo "<a href="members.php">Go there now</a></br>"; ?> anyone help me figure otu what I did wrong? Link to comment https://forums.phpfreaks.com/topic/42369-solved-registration-script-problems/ Share on other sites More sharing options...
papaface Posted March 12, 2007 Share Posted March 12, 2007 You shouldnt do this: @mysql_select_db Remove the @'s Then see if you have any errors. Also add this to the top of your page and see if you get any error_reporting(E_ALL); ini_set('display_errors', '1'); Link to comment https://forums.phpfreaks.com/topic/42369-solved-registration-script-problems/#findComment-205518 Share on other sites More sharing options...
interpim Posted March 12, 2007 Author Share Posted March 12, 2007 ok... removed the @'s and put that code you posted at the top... I still get a blank page back. Link to comment https://forums.phpfreaks.com/topic/42369-solved-registration-script-problems/#findComment-205528 Share on other sites More sharing options...
interpim Posted March 12, 2007 Author Share Posted March 12, 2007 Here is my changed code... still outputting a blank page. <?php error_reporting(E_ALL); ini_set('display_errors', '1'); include('config.php'); include('includes/functions.php'); $user=$_POST['username']; $pword=$_POST['password']; $pword2=$_POST['password2']; $email=$_POST['email']; if (empty($user) || empty($pword) || empty($email)) { header("Location: register.php?err=1"); exit(); } mysql_connect($server,$username,$password); mysql_select_db($database) or die("unable to select database"); $query="SELECT * FROM main WHERE user_name='$user'"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); if ($num!=0) { echo "That username has already been taken, please try again<br> <a href='register.php'>Register</a>"; exit(); } elseif ($pword!=$pword2) { echo "The supplied passwords you gave do not match<br><a href='register.php'>Try Again</a><br>"; exit(); } mysql_connect($server,$username,$password); mysql_select_db($database) or die("unable to select database"); $af=0; $query = "INSERT INTO main VALUES('','$user','$pword','','','','','','','','','','','','$af','','$code','','','','','','','$email','','','')"; mysql_query($query); mysql_close(); setcookie("user","$user"); setcookie("loggedin","true",time()+(86400*5)); $code=code_gen(); $reg_sub="Ambassade Game Registration confirmation email"; $reg_body="Thank you for registering for Ambassade... before you can log in, you must confirm your email by entering the following code on our website./n/n/n/n $code /n/n/n/n Thank you again, /n/n Team Ambassade."; mail($email,$reg_sub,$reg_body); echo "Thank you for registering... you will shortly receive an email with a confirmation code<br>"; echo "<a href="members.php">Go there now</a></br>"; ?> Link to comment https://forums.phpfreaks.com/topic/42369-solved-registration-script-problems/#findComment-205563 Share on other sites More sharing options...
interpim Posted March 12, 2007 Author Share Posted March 12, 2007 OK... i atleast fixed that first problem, i had double quotes in an echo statement instead of single quotes and it was killing the entire script... It is giving me an error now, saying that there is an undefined variable on line 41... which is $af=0; One more quick question... how would I echo new lines in an email body... the /n's I put into the body actually displayed in the email. Link to comment https://forums.phpfreaks.com/topic/42369-solved-registration-script-problems/#findComment-205567 Share on other sites More sharing options...
interpim Posted March 12, 2007 Author Share Posted March 12, 2007 any help on the spacing out of an email? /n in the string didn't work LOL Link to comment https://forums.phpfreaks.com/topic/42369-solved-registration-script-problems/#findComment-205665 Share on other sites More sharing options...
aebstract Posted March 12, 2007 Share Posted March 12, 2007 In your code, just press enter and go to the next line, it will do the same when the email sends out. For example: $body = "this is my body message and this line is down a few"; Doing that should cause space in the email, that has worked for me in the past anyway, so give that a shot and see if you get what you wanted out of it. Link to comment https://forums.phpfreaks.com/topic/42369-solved-registration-script-problems/#findComment-205668 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.