aspdude2004
05-04-2004, 08:44 PM
what the hell is wrong with this code ??? please help
<html>
<head>
<title></title>
</head>
<body>
<?
// set this
$db_host = "localhost";
$db_username = "root";
$db_password = "*******";
$database = "mydb";
// REGISTER
// ok always remember this baby ;)
if($_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'];
// 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
if(!$name) {
echo "<font color=\"red\"><b>Please enter your first name</font></b>";
die;
}
if(!$lname) {
echo "<font color=\"red\"><b>Please enter your last name</font></b>";
die;
}
if(!$email) {
echo "<font color=\"red\"><b>Please enter your email</font></b>";
die;
}
if(!$user) {
echo "<font color=\"red\"><b>Please enter a username</font></b>";
die;
}
if(!$pass) {
echo "<font color=\"red\"><b>Please enter a password</font></b>";
die;
}
// make the password md5 secure ;)
$monkey = $pass;
$pass = md5($pass);
// see if they already exist
$username_check = mysql_query("SELECT username FROM users WHERE username='$username'");
$email_check = mysql_query("SELECT email_address FROM users WHERE email_address='$email'");
$norow_username = mysql_num_rows($username_check);
$norow_email = mysql_num_rows($email_check);
if ($norow_username > 0) {
echo "<font color=/"red/"><b>Sorry username already exists :D</b></font>";
unset($user);
die;
}
if ($norow_email > 0) {
echo "<font color=\"red\"><b>Sorry email address is already registered</b></font>";
unset($email);
die;
}
// ok lets put it in :D
$conn = mysql_connect($db_host,$db_username,$db_password) or die ("Problems connecting to mysql".mysql_error());
mysql_select_db ($database,$conn) or die ("Could not select database");
// connected!
//oops forgot to register time ;)
$mydate = now();
$queryone = "INSERT INTO users
('first_name','last_name','email_address','username','password','age','signup_date')
VALUES
('$name','$lname','$email','$user','$pass','$mydate')";
mysql_query($queryone, $conn);
if(!queryone) {
echo "There has been a error creating your account";
} else {
$userid = mysql_insert_id();
$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!";
mail($to, $subject, $message,
"From: TiG\n
X-Mailer: PHP/" . phpversion());
echo "Your membership details have been mailed to the address supplied please follow the instructions in the email";
}
}else {
?>
<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>
<?
}
?>
</body>
</html>
I just get a blank screen , argh :)
<html>
<head>
<title></title>
</head>
<body>
<?
// set this
$db_host = "localhost";
$db_username = "root";
$db_password = "*******";
$database = "mydb";
// REGISTER
// ok always remember this baby ;)
if($_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'];
// 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
if(!$name) {
echo "<font color=\"red\"><b>Please enter your first name</font></b>";
die;
}
if(!$lname) {
echo "<font color=\"red\"><b>Please enter your last name</font></b>";
die;
}
if(!$email) {
echo "<font color=\"red\"><b>Please enter your email</font></b>";
die;
}
if(!$user) {
echo "<font color=\"red\"><b>Please enter a username</font></b>";
die;
}
if(!$pass) {
echo "<font color=\"red\"><b>Please enter a password</font></b>";
die;
}
// make the password md5 secure ;)
$monkey = $pass;
$pass = md5($pass);
// see if they already exist
$username_check = mysql_query("SELECT username FROM users WHERE username='$username'");
$email_check = mysql_query("SELECT email_address FROM users WHERE email_address='$email'");
$norow_username = mysql_num_rows($username_check);
$norow_email = mysql_num_rows($email_check);
if ($norow_username > 0) {
echo "<font color=/"red/"><b>Sorry username already exists :D</b></font>";
unset($user);
die;
}
if ($norow_email > 0) {
echo "<font color=\"red\"><b>Sorry email address is already registered</b></font>";
unset($email);
die;
}
// ok lets put it in :D
$conn = mysql_connect($db_host,$db_username,$db_password) or die ("Problems connecting to mysql".mysql_error());
mysql_select_db ($database,$conn) or die ("Could not select database");
// connected!
//oops forgot to register time ;)
$mydate = now();
$queryone = "INSERT INTO users
('first_name','last_name','email_address','username','password','age','signup_date')
VALUES
('$name','$lname','$email','$user','$pass','$mydate')";
mysql_query($queryone, $conn);
if(!queryone) {
echo "There has been a error creating your account";
} else {
$userid = mysql_insert_id();
$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!";
mail($to, $subject, $message,
"From: TiG\n
X-Mailer: PHP/" . phpversion());
echo "Your membership details have been mailed to the address supplied please follow the instructions in the email";
}
}else {
?>
<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>
<?
}
?>
</body>
</html>
I just get a blank screen , argh :)