Jump to content

Account Creation help


omglolnub

Recommended Posts

I've been trying to fix this code for a couple of days.It used work but after I tried to add checking for things like account already exists, email already in user, passwords do not match and such it fail to keep working. It does not error out until the end (the query for Char) but the checking seems to not work (can still create two accounts with same name/email and can enter different passwords.

 

<?php
include 'DBopen.php';
$Acc = $_POST['acc'];
$Pwd1 = md5($_POST['pwd1']);
$Pwd2 = md5($_POST['pwd2']);
$Email1 = $_POST['email1'];
$Email2 = $_POST['email2'];
$Class = $_POST['class'];
$Gender = $_POST['gender'];

if ($Pwd1 != $Pwd2){
setcookie('msg','Passwords do not match!',0);
header ( "http://gunners.freehostia.com/CreateAccount.php" );
}

if ($Email1 != $Email2){
setcookie('msg','Emails do not match!',0);
header ( "http://gunners.freehostia.com/CreateAccount.php" );
}

$sql = "SELECT * FROM Player WHERE Acc = '$Acc'";
$result = mysql_query($sql) or die ('Errrrror');
$rows = mysql_num_rows($result);
if ($rows == 1){
setcookie('msg','Account name already in use.',0);
header ( "http://gunners.freehostia.com/CreateAccount.php" );
};


$sql2 = "SELECT * FROM Player WHERE Email = '$Email1'";
$result2 = mysql_query($sql2) or die ('Nope');
$rows1 = mysql_num_rows($result2);
if ($rows2 == 1){
setcookie('msg','Email already in use!',0);
header ( "http://gunners.freehostia.com/CreateAccount.php" );
};
if ($Class = 'class1'){
$Str = 3;
$Int = 3;
$Dex = 2;
};
if ($Class = 'class2'){
$Str = 3;
$Int = 2;
$Dex = 3;
};
if ($Class = 'class3'){
$Str = 3;
$Int = 3;
$Dex = 2;
};
if ($Class = 'class4'){
$Str = 2;
$Int = 3;
$Dex = 2;
};
if ($Class = 'class5'){
$Str = 3;
$Int = 2;
$Dex = 3;
};
if ($Class = 'class6'){
$Str = 2;
$Int = 3;
$Dex = 3;
};
$query = "INSERT INTO Player ( Acc, Pwd, Email, Admin) VALUES ( '$Acc', '$Pwd1', '$Email1', '0')";
mysql_query ($query) or die ('Error you fucked up');

$query2 = "INSERT INTO Char ( Name, Class, Gender, Str, Int, Dex, BStr, BInt, BDex) VALUES ( '$Acc', '$Class', '$Gender', '$Str', '$Int', '$Dex', '0', '0', '0')";
mysql_query ($query2) or die ('Error you fucked up');

setcookie('msg','Account Created!,',0);
//header ("Location: http://gunners.freehostia.com");
echo "$query2";
?>

Thanks in advance.

 

~The Nub~

Link to comment
https://forums.phpfreaks.com/topic/106708-account-creation-help/
Share on other sites

(supposedly) Fixed code:

<?php
include 'DBopen.php';
$Acc = $_POST['acc'];
$Pwd1 = md5($_POST['pwd1']);
$Pwd2 = md5($_POST['pwd2']);
$Email1 = $_POST['email1'];
$Email2 = $_POST['email2'];
$Class = $_POST['class'];
$Gender = $_POST['gender'];

if ($Pwd1 != $Pwd2){
setcookie('msg','Passwords do not match!',0);
header ( "http://gunners.freehostia.com/CreateAccount.php" );
}

if ($Email1 != $Email2){
setcookie('msg','Emails do not match!',0);
header ( "http://gunners.freehostia.com/CreateAccount.php" );
}

$sql = "SELECT * FROM Player WHERE Acc = '$Acc'";
$result = mysql_query($sql) or die ('Errrrror');
$rows = mysql_num_rows($result);
if ($rows == 1){
setcookie('msg','Account name already in use.',0);
header ( "http://gunners.freehostia.com/CreateAccount.php" );
};


$sql2 = "SELECT * FROM Player WHERE Email = '$Email1'";
$result2 = mysql_query($sql2) or die ('Nope');
$rows1 = mysql_num_rows($result2);
if ($rows1 == 1){
setcookie('msg','Email already in use!',0);
header ( "http://gunners.freehostia.com/CreateAccount.php" );
};
if ($Class == 'class1'){
$Str = 3;
$Int = 3;
$Dex = 2;
};
if ($Class == 'class2'){
$Str = 3;
$Int = 2;
$Dex = 3;
};
if ($Class == 'class3'){
$Str = 3;
$Int = 3;
$Dex = 2;
};
if ($Class == 'class4'){
$Str = 2;
$Int = 3;
$Dex = 2;
};
if ($Class == 'class5'){
$Str = 3;
$Int = 2;
$Dex = 3;
};
if ($Class == 'class6'){
$Str = 2;
$Int = 3;
$Dex = 3;
};
$query = "INSERT INTO Player ( Acc, Pwd, Email, Admin) VALUES ( '$Acc', '$Pwd1', '$Email1', '0')";
mysql_query ($query) or die ('Error you fucked up');

$query2 = "INSERT INTO Char ( Name, Class, Gender, Str, Int, Dex, BStr, BInt, BDex) VALUES ( '$Acc', '$Class', '$Gender', '$Str', '$Int', '$Dex', '0', '0', '0')";
mysql_query ($query2) or die ('Error you fucked up');

setcookie('msg','Account Created!,',0);
//header ("Location: http://gunners.freehostia.com");
echo "$query2";
?>

After changing the error checking to something useful this is what I'm getting.

 

 

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Char ( Name, Class, Gender, Str, Int, Dex, BStr, BInt, BDex) VAL

 

Any ideas?

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.