Ack! its 12:00am and my eyes are slamming shut. i had my first go at trying to learn php, and i think i learned a lot by following along in this login system tutorial. i learned how to do all the things in the code below. but what it reaaaaalllllyyyyyy irritating me is this error when i try to execute the script. it says "Parse error: syntax error, unexpected '{' in /var/www/loginsys/register.php on line 42"
i have marked line number 42 with this: ">>>> 42 >>>>"
by the way this isnt a site for gangsters or anything lol, i just used some funny lines (that i thought were funny anyway) to make things more interesting lol
PHP Code:
<?
//DB connector script
include 'db.php';
//Information collecter
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email_address = $_POST['email_address'];
$username = $_POST['username'];
$info = $_POST['info'];
//Escaped character remover
$first_name = stripslashes($first_name);
$last_name = stripslashes($last_name);
$email_address = stripslashes($email_address);
$username = stripslashes($username);
$info = stripslashes($info);
//Error checker and debugger
if((!$first_name) || (!$email_address) || (!$username)){
echo "You didn\'t completely fill out your stuff. REDO IT!!!
";
if(!$first_name){
echo "You need to fill out your first name homie. I needa know what to call ya!
";
}
if(!$email_address){
echo "I\'m gonna need your email address. How else am I going to contact you with your password!?!? jeez!
";
}
if(!$username){
echo "You need something to log in with... doh!
";
}
include 'index.html';
exit();
}
//Duplicate entry checker
$sql_email_check = mysql_query("SELECT email_address FROM users WHERE email_address='$email_address'");
$sql_username_check = mysql_query("SELECT username FROM ysers WHERE username='$username'");
$email_check = mysql_num_rows($sql_email_check);
$username_check = mysql_num_rows($sql_username_check);
[color=red]>>>> 42 >>>>[/color]if(($email_check > 0 || ($username_check > 0)) {
echo "Let\'s check to see if your email address or username is already in use
";
if($email_check > 0){
echo "Looks like you\'ve already registered this email address here. Don\'t know what to tell ya lol... get a new email address or remember your old password!
";
unset($email_address);
}
if($username_check > 0){
echo "Someone done lifted yo username! homie, you gosta try da add some numbuhs afta it or somethin\'!!";
unset($username);
}
include 'index.html';
exit();
}
//This is our nifty random password generater!
function makeRandomPassword() {
$salt = "abcdefghijklmnopqrstuvwxyz1234567890";
srand((double)microtime()*1000000);
$i = 0;
while $i <= 7) {
$num = rand() % 33;
$tmp = substr($salt, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}
$random_password = makeRandomPassword();
$db_password = md5($random_password);
//Put it in the sql table!
$info2 = htmlspecialcharacters($info);
$sql = mysql_query("INSERT INTO users (first_name, last_name, email_address, username, password, info, signup_date)
VALUES('$first_name', '$last_name', '$email_address', '$username', '$password', '$info', now())") or die (mysql_error());
if (!$sql){
echo 'Our bad, our system is broke. You\'ve basically wasted your time. Sorry';
} else {
$userid = mysql_insert_id();
//Lets send an email to our new registrant. woot.
$subject = "Registration at sapphireconcepts.net!";
$message = "Dear $first_name,
You are the pwnage for registering. But there IS one more thing you gosta do homie. Just click this link to activate your account: [url]http://67.170.117.94/loginsys/activate.php?id=[/url]$userid&code=$db_password
Once you do all that stuff, you can log in with this stuff:
Username: $username
Password: $random_password
That password is pretty goofy lookin but yknow, you can change it. If it wasnt this way, then ppl could haxzorz j00!!
Appreciate it homie,
sapphireconcepts staff
This aint a real peep right here, so dont respond cause you aint gonna get an answer!";
mail($email_address, $subject, $message,
"From: sapphireconcepts <laser.viking@gmail.com>\n
X-Mailer: PHP/" . phpversion());
echo 'Aight, I hooked you up with all yo account information at the email address you told me, so it better not be fake! If it iz you betta back yoself up and fix it!';
}
?>