aspdude2004
05-06-2004, 10:41 PM
Can anyone please tell me what is wrong with this script:
I get a blank screen and nothing comes up,
<html>
<head>
<title>Register</title>
</head>
<body>
<?
// error_reporting();
$conn = mysql_connect("localhost","root","triadpass");
mysql_select_db("mydb", $conn)or die("Could not select database");
//take out later
// function to display form ;)
function formcall() {
?>
<form method=post action='register.php'>
<b>First Name* : </b><input type='text' name='name'><br />
<b>Last Name* : </b><input type='text' name='lname'><br />
<b>Email Address*: </b><input type='text' name='email'><br />
<b>Age* : </b><input type='text' name='age'><br />
<b>Username* : </b><input type='text' name='user'><br />
<b>Password* : </b><input type='text' name='pass'><br />
<input type='submit' name='submit'><br>
<b>* = Required</b>
</form>
<?
}
// REGISTER
// ok always remember this ;)
if(isset($_POST['submit'])) {
// lets check they didnt leave the god damned things blank
// for future reference
// name = $name = $_POST['name']
// lastname = $lname = $_POST['lname']
// email address = $email = $_POST['email']
// age = $age = $_POST['age']
// username = $user = $_POST['user']
// password = $pass = $_POST['pass'] remember to md5
// signdate = now()
$name = $_POST['name'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$user = $_POST['user'];
$pass = $_POST['pass'];
$age = $_POST['age'];
$submit = $_POST['submit'];
// make sure no users typed any characters that they shouldnt have
$name = stripslashes($name);
$lname = stripslashes($lname);
$email = stripslashes($email);
$user = stripslashes($user);
$age = stripslashes($age);
//check if they entered it
$username_check = mysql_query("SELECT * FROM users WHERE username='$user'");
$email_check = mysql_query("SELECT * FROM users WHERE email_address='$email'");
$norow_username = mysql_num_rows($username_check);
$norow_email = mysql_num_rows($email_check);
// error check
if(!$name||!$lname||!$email||!$user||!$pass||$norow_username > 0||$norow_email > 0) {
if(!$name) {
echo "<font color=\"red\"><b>Please enter your first name</font></b><br>";
}
if(!$lname) {
echo "<font color=\"red\"><b>Please enter your last name</font></b><br>";
}
if(!$email) {
echo "<font color=\"red\"><b>Please enter your email</font></b><br>";
}
if(!$user) {
echo "<font color=\"red\"><b>Please enter a username</font></b><br>";
}
if(!$pass) {
echo "<font color=\"red\"><b>Please enter a password</font></b><br>";
}
if ($norow_username > 0) {
echo "<font color=\"red\"><b>Sorry username already exists :D</b></font>";
}
if ($norow_email > 0) {
echo "<font color=\"red\"><b>Sorry email address is already registered</b></font>";
}
formcall();
}
// make the password md5 secure ;)
$monkey = $pass;
$pass = md5($pass);
// see if they already exist
// ok lets put it in :D
// error_reporting(E_ALL);
// connected!
//oops forgot to register time ;)
$mydate = now();
//CONNECT TO DATABASE
$checkquery = "SELECT 'userID' FROM 'users' WHERE username='$user' AND password='$pass'";
$checkquery_res = mysql_query($checkquery, $conn);
$querys = "
INSERT INTO users(first_name, last_name, email_address, username, password, age, signup_date)
VALUES('$name','$lname','$email','$user','$pass','$mydate')";
if (mysql_query($querys,$conn)) {
//IF INSERT QUERY IS SUCCESSFULL
//WHY HAVE YOU PUT THIS HERE? YOU DONT USE IT...
$userid = mysql_result($checkquery_res, 0, 'userid');
//CONSTRUCTING MAIL
$to = $email;
$subject = "Membership at TiG, $name $lname";
$message = "Dear $name $lname
you have recently signed up at TiG, we thank you for this...
you must click the link below to activate your account thank you
click here: http://tig.deathdragon.net/test/activate.php?id=".$userid"&code=".$pass"
if the link does not appear copy the link to your address bar
You signed up with the following information
Username : ".$user"
Password : ".$monkey"
Thanks!
TiG Staff
This is a automatic response please do not reply!";
$headers = "From: TiG\n
X-Mailer: PHP/" . phpversion();
mail($to, $subject, $message, $headers);
print "Your membership details have been mailed to the address supplied please follow the instructions in the email";
} else {
//IF INSERT QUERY IS UNSUCCESSFULL
formcall();
}
}else{
formcall();
}
?>
</body>
</html>
i swear , i fix this and i wont bother you lot again ;)
by the way the error_reporting(E_ALL); does not work
I get a blank screen and nothing comes up,
<html>
<head>
<title>Register</title>
</head>
<body>
<?
// error_reporting();
$conn = mysql_connect("localhost","root","triadpass");
mysql_select_db("mydb", $conn)or die("Could not select database");
//take out later
// function to display form ;)
function formcall() {
?>
<form method=post action='register.php'>
<b>First Name* : </b><input type='text' name='name'><br />
<b>Last Name* : </b><input type='text' name='lname'><br />
<b>Email Address*: </b><input type='text' name='email'><br />
<b>Age* : </b><input type='text' name='age'><br />
<b>Username* : </b><input type='text' name='user'><br />
<b>Password* : </b><input type='text' name='pass'><br />
<input type='submit' name='submit'><br>
<b>* = Required</b>
</form>
<?
}
// REGISTER
// ok always remember this ;)
if(isset($_POST['submit'])) {
// lets check they didnt leave the god damned things blank
// for future reference
// name = $name = $_POST['name']
// lastname = $lname = $_POST['lname']
// email address = $email = $_POST['email']
// age = $age = $_POST['age']
// username = $user = $_POST['user']
// password = $pass = $_POST['pass'] remember to md5
// signdate = now()
$name = $_POST['name'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$user = $_POST['user'];
$pass = $_POST['pass'];
$age = $_POST['age'];
$submit = $_POST['submit'];
// make sure no users typed any characters that they shouldnt have
$name = stripslashes($name);
$lname = stripslashes($lname);
$email = stripslashes($email);
$user = stripslashes($user);
$age = stripslashes($age);
//check if they entered it
$username_check = mysql_query("SELECT * FROM users WHERE username='$user'");
$email_check = mysql_query("SELECT * FROM users WHERE email_address='$email'");
$norow_username = mysql_num_rows($username_check);
$norow_email = mysql_num_rows($email_check);
// error check
if(!$name||!$lname||!$email||!$user||!$pass||$norow_username > 0||$norow_email > 0) {
if(!$name) {
echo "<font color=\"red\"><b>Please enter your first name</font></b><br>";
}
if(!$lname) {
echo "<font color=\"red\"><b>Please enter your last name</font></b><br>";
}
if(!$email) {
echo "<font color=\"red\"><b>Please enter your email</font></b><br>";
}
if(!$user) {
echo "<font color=\"red\"><b>Please enter a username</font></b><br>";
}
if(!$pass) {
echo "<font color=\"red\"><b>Please enter a password</font></b><br>";
}
if ($norow_username > 0) {
echo "<font color=\"red\"><b>Sorry username already exists :D</b></font>";
}
if ($norow_email > 0) {
echo "<font color=\"red\"><b>Sorry email address is already registered</b></font>";
}
formcall();
}
// make the password md5 secure ;)
$monkey = $pass;
$pass = md5($pass);
// see if they already exist
// ok lets put it in :D
// error_reporting(E_ALL);
// connected!
//oops forgot to register time ;)
$mydate = now();
//CONNECT TO DATABASE
$checkquery = "SELECT 'userID' FROM 'users' WHERE username='$user' AND password='$pass'";
$checkquery_res = mysql_query($checkquery, $conn);
$querys = "
INSERT INTO users(first_name, last_name, email_address, username, password, age, signup_date)
VALUES('$name','$lname','$email','$user','$pass','$mydate')";
if (mysql_query($querys,$conn)) {
//IF INSERT QUERY IS SUCCESSFULL
//WHY HAVE YOU PUT THIS HERE? YOU DONT USE IT...
$userid = mysql_result($checkquery_res, 0, 'userid');
//CONSTRUCTING MAIL
$to = $email;
$subject = "Membership at TiG, $name $lname";
$message = "Dear $name $lname
you have recently signed up at TiG, we thank you for this...
you must click the link below to activate your account thank you
click here: http://tig.deathdragon.net/test/activate.php?id=".$userid"&code=".$pass"
if the link does not appear copy the link to your address bar
You signed up with the following information
Username : ".$user"
Password : ".$monkey"
Thanks!
TiG Staff
This is a automatic response please do not reply!";
$headers = "From: TiG\n
X-Mailer: PHP/" . phpversion();
mail($to, $subject, $message, $headers);
print "Your membership details have been mailed to the address supplied please follow the instructions in the email";
} else {
//IF INSERT QUERY IS UNSUCCESSFULL
formcall();
}
}else{
formcall();
}
?>
</body>
</html>
i swear , i fix this and i wont bother you lot again ;)
by the way the error_reporting(E_ALL); does not work