kaspm Posted March 7, 2006 Share Posted March 7, 2006 Hi, im having problems with a login script Im trying to use for a website. When a person goes to register it says "We are sorry, it appears we are having problems with our script at the moment." I was wondering if someone could look at the code and see if they can find an error. Thanks Quote Link to comment Share on other sites More sharing options...
php_b34st Posted March 7, 2006 Share Posted March 7, 2006 If you post the code here someone will look at it and you will most likely get help with your problems. Quote Link to comment Share on other sites More sharing options...
kaspm Posted March 7, 2006 Author Share Posted March 7, 2006 Im having trouble posting the code how do i do it Quote Link to comment Share on other sites More sharing options...
php_b34st Posted March 7, 2006 Share Posted March 7, 2006 if you click the hash button above the box where you add a full reply then copy and paste your code then press the button again it will show in a code box and be easier to read Quote Link to comment Share on other sites More sharing options...
kaspm Posted March 7, 2006 Author Share Posted March 7, 2006 its not working Quote Link to comment Share on other sites More sharing options...
php_b34st Posted March 7, 2006 Share Posted March 7, 2006 how are you copying the code? just highlight it all, right click then click copy then right click to paste here Quote Link to comment Share on other sites More sharing options...
kaspm Posted March 7, 2006 Author Share Posted March 7, 2006 When i press the "#" button it opens a script prompt but only pastes the first line of code Quote Link to comment Share on other sites More sharing options...
php_b34st Posted March 7, 2006 Share Posted March 7, 2006 ok just paste your code between [ code ]CODE GOES HERE[ /code ] (remove the spaces) Quote Link to comment Share on other sites More sharing options...
kaspm Posted March 7, 2006 Author Share Posted March 7, 2006 [code]<?phpinclude 'config.php';if(isset($_POST['submit'])){$first = addslashes(trim($_POST['firstname']));$surname = addslashes(trim($_POST['surname']));$username = addslashes(trim($_POST['username']));$email = addslashes(trim($_POST['email']));$pass = addslashes(trim($_POST['password']));$conf = addslashes(trim($_POST['confirm']));$ip = $_SERVER['REMOTE_ADDR'];$date = date("d, m y");if ( $_POST['password'] == $_POST['confirm'] ){}else{echo 'alert("Your passwords were not the same, please enter the same password in each field.");echo 'history.back(1);exit;}$password = md5($pass);if ((((( empty($first) ) || ( empty($surname) ) || ( empty($username) ) || ( empty($email) ) || ( empty($password) ))))){echo 'alert("One or more fields was left empty, please try again.");echo 'history.back(1);exit;}if((!strstr($email , "@")) || (!strstr($email , "."))){echo 'alert("You entered an invalid email address. Please try again.");echo 'history.back(1);exit;}$q = mysql_query("SELECT * FROM Users WHERE Username = '$username'") or die(mysql_error());if(mysql_num_rows($q) > 0){echo 'alert("The username you entered is already in use, please try again.");echo 'history.back(1)exit;}$name = $first . ' ' . $surname;$actkey = mt_rand(1, 500).'f78dj899dd';$act = sha1($actkey);$query = mysql_query("INSERT INTO Users (Username, Password, Name, Email, Date, IP, Actkey) VALUES ('$username','$password','$name','$email','$date','$ip','$act')") or die(mysql_error());$send = mail($email , "Registration Confirmation" , "Thank you for registering with PhotoCards&Calendars.\n\nYour username and password is below, along with details on how to activate your account.\n\nUser: ".$username."\nPass: ".$pass."\n\nClick the link below to activate your account:\nhttp://www.photocardsandcalendars.com/activate.php?id=".$act."\n\nPlease do not reply, this is an automated mailer.\n\nThanks", "FROM: sales@photocardsandcalendars.com.com");if(($query)&&($send)){echo ' Thank you for registering, you will recieve an email soon with your login details and your activation link so that you can activate your accounta href="login.php"Click here to login once you have activated'; } else {echo 'We are sorry, there appears to be a problem with our script at the moment.Your data was not lost. Username: '.$username.' | Password: '.$pass.' | Email: '.$email.' | Full name: '.$name.'Please try again later.'; }} else {?> Quote Link to comment Share on other sites More sharing options...
php_b34st Posted March 7, 2006 Share Posted March 7, 2006 I found a few errors in your script where you hadnt closed your echo statements or your first if statement try the following:[code]<?phpinclude 'config.php';if(isset($_POST['submit'])){$first = addslashes(trim($_POST['firstname']));$surname = addslashes(trim($_POST['surname']));$username = addslashes(trim($_POST['username']));$email = addslashes(trim($_POST['email']));$pass = addslashes(trim($_POST['password']));$conf = addslashes(trim($_POST['confirm']));$ip = $_SERVER['REMOTE_ADDR'];$date = date("d, m y");if ( $_POST['password'] == $_POST['confirm'] ){}else{echo 'alert("Your passwords were not the same, please enter the same password in each field.")';echo 'history.back(1)';exit;}$password = md5($pass);if ((((( empty($first) ) || ( empty($surname) ) || ( empty($username) ) || ( empty($email) ) || ( empty($password) ))))){echo 'alert("One or more fields was left empty, please try again.")';echo 'history.back(1)';exit;}if((!strstr($email , "@")) || (!strstr($email , "."))){echo 'alert("You entered an invalid email address. Please try again.")';echo 'history.back(1)';exit;}$q = mysql_query("SELECT * FROM Users WHERE Username = '$username'") or die(mysql_error());if(mysql_num_rows($q) > 0){echo 'alert("The username you entered is already in use, please try again.")';echo 'history.back(1)'exit;}$name = $first . ' ' . $surname;$actkey = mt_rand(1, 500).'f78dj899dd';$act = sha1($actkey);$query = mysql_query("INSERT INTO Users (Username, Password, Name, Email, Date, IP, Actkey) VALUES ('$username','$password','$name','$email','$date','$ip','$act')") or die(mysql_error());$send = mail($email , "Registration Confirmation" , "Thank you for registering with PhotoCards&Calendars.\n\nYour username and password is below, along with details on how to activate your account.\n\nUser: ".$username."\nPass: ".$pass."\n\nClick the link below to activate your account:\nhttp://www.photocardsandcalendars.com/activate.php?id=".$act."\n\nPlease do not reply, this is an automated mailer.\n\nThanks", "FROM: sales@photocardsandcalendars.com.com");if(($query)&&($send)){echo 'Thank you for registering, you will recieve an email soon with your login details and your activation link so that you can activate your accounta href="login.php"Click here to login once you have activated';} }else {echo 'We are sorry, there appears to be a problem with our script at the moment.Your data was not lost. Username: '.$username.' | Password: '.$pass.' | Email: '.$email.' | Full name: '.$name.'Please try again later.';}?>[/code] Quote Link to comment Share on other sites More sharing options...
kaspm Posted March 7, 2006 Author Share Posted March 7, 2006 ok ill try that thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.