Jump to content

Login Script Error-Please Help


kaspm

Recommended Posts

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
Link to comment
Share on other sites

[code]<?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 {

?>
Link to comment
Share on other sites

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

[code]<?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.

';

}

?>[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.