Jump to content


Photo

Login Script Error-Please Help


  • Please log in to reply
10 replies to this topic

#1 kaspm

kaspm
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 07 March 2006 - 10:16 PM

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

#2 php_b34st

php_b34st
  • Members
  • PipPipPip
  • Advanced Member
  • 168 posts

Posted 07 March 2006 - 10:22 PM

If you post the code here someone will look at it and you will most likely get help with your problems.

#3 kaspm

kaspm
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 07 March 2006 - 10:23 PM

Im having trouble posting the code how do i do it


#4 php_b34st

php_b34st
  • Members
  • PipPipPip
  • Advanced Member
  • 168 posts

Posted 07 March 2006 - 10:26 PM

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

#5 kaspm

kaspm
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 07 March 2006 - 10:37 PM

its not working

#6 php_b34st

php_b34st
  • Members
  • PipPipPip
  • Advanced Member
  • 168 posts

Posted 07 March 2006 - 10:53 PM

how are you copying the code? just highlight it all, right click then click copy then right click to paste here

#7 kaspm

kaspm
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 07 March 2006 - 10:59 PM

When i press the "#" button it opens a script prompt but only pastes the first line of code

#8 php_b34st

php_b34st
  • Members
  • PipPipPip
  • Advanced Member
  • 168 posts

Posted 07 March 2006 - 11:01 PM

ok just paste your code between [ code ]CODE GOES HERE[ /code ] (remove the spaces)

#9 kaspm

kaspm
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 07 March 2006 - 11:15 PM

[code=auto:0]<?php

include '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 account
a 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 {

?>

#10 php_b34st

php_b34st
  • Members
  • PipPipPip
  • Advanced Member
  • 168 posts

Posted 07 March 2006 - 11:42 PM

I found a few errors in your script where you hadnt closed your echo statements or your first if statement try the following:

<?php

include '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 account
a 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.

';

}

?>


#11 kaspm

kaspm
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 07 March 2006 - 11:49 PM

ok ill try that thanks




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users