Jump to content

Login Script Error-Please Help


kaspm

Recommended Posts

[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: [email protected]");

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 {

?>
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: [email protected]");

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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.