Jump to content

Archived

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

kaspm

Login Script Error-Please Help

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

Share this post


Link to post
Share on other sites
If you post the code here someone will look at it and you will most likely get help with your problems.

Share this post


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

Share this post


Link to post
Share on other sites
how are you copying the code? just highlight it all, right click then click copy then right click to paste here

Share this post


Link to post
Share on other sites
When i press the "#" button it opens a script prompt but only pastes the first line of code

Share this post


Link to post
Share on other sites
ok just paste your code between [ code ]CODE GOES HERE[ /code ] (remove the spaces)

Share this post


Link to post
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 {

?>

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

×

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.