A
AngelMare
Guest
It looks fine when I go to my website to the register.php page, and when I fill out the form, it says you are registered, but nothing is created in the database.
Here is the code; hope some of you can see anything wrong here. Please help, I've gotten so mad at it.
Sorry it's so long.
<link rel="stylesheet" type="text/css" href="hw.css">
<?php
// Connects to your Database
mysql_connect("--", "--", "--") or die(mysql_error());
mysql_select_db("--") or die(mysql_error());
//This code runs if the form has been submitted
if (isset($_POST['submit'])) {
//This makes sure they did not leave any fields blank
if (!$_POST['username'] | !$_POST['password'] | !$_POST['pass2'] | !$_POST['email'] | !$_POST['country'] | !$_POST['nick'] ) {
die('You did not complete all of the required fields');
}
// checks if the username is in use
if (!get_magic_quotes_gpc()) {
$_POST['username'] = addslashes($_POST['username']);
}
$usercheck = $_POST['username'];
$check = mysql_query("SELECT username FROM players WHERE username = '$usercheck'")
or die(mysql_error());
$check2 = mysql_num_rows($check);
//if the name exists it gives an error
if ($check2 != 0) {
die('Sorry, the username '.$_POST['username'].' is already in use.');
}
// this makes sure both passwords entered match
if ($_POST['password'] != $_POST['pass2']) {
die('Your passwords did not match. ');
}
// here we encrypt the password and add slashes if needed
$_POST['password'] = md5($_POST['password']);
if (!get_magic_quotes_gpc()) {
$_POST['password'] = addslashes($_POST['password']);
$_POST['username'] = addslashes($_POST['username']);
}
$date = date("m/d/y");
$ip=@$REMOTE_ADDR;
// now we insert it into the database
$insert = "INSERT INTO players (ip, sponsor, username, password, nick, country, email, registered)
VALUES ($ip, $sponsor, $username, $password, $nick, $country, $email, $date)";
$add_player = mysql_query($insert);
?>
<h1>Registered</h1>
<p>Thank you, you have registered - you may now <a href=login.php>login</a>.</p>
<?php
}
else
{
?>
<form action=register.php method=post>
<table border=0>
<tr><td>Sponsor (optional):</td><td>
<input type=text name=sponsor>
</td></tr>
<tr><td>Username (what you use to login):</td><td>
<input type=text name=username>
</td></tr>
<tr><td>Nickname:</td><td>
<textarea name=nick rows=4 cols=30>Your nickname may be changed later; it may contain html and it may be the same as your username</textarea>
</td></tr>
<tr><td>Country:</td><td>
<input type=text name="country">
</td></tr>
<tr><td>E-mail Address:</td><td>
<input type=text name=email>
</td></tr>
<tr><td>Password:</td><td>
<input type=password name=password>
</td></tr>
<tr><td>Confirm Password:</td><td>
<input type=password name=pass2>
</td></tr>
<tr><th colspan=2><input type=submit name=submit value=Register></th></tr> </table>
</form>
<?php
}
?>
Here is the code; hope some of you can see anything wrong here. Please help, I've gotten so mad at it.

Sorry it's so long.
<link rel="stylesheet" type="text/css" href="hw.css">
<?php
// Connects to your Database
mysql_connect("--", "--", "--") or die(mysql_error());
mysql_select_db("--") or die(mysql_error());
//This code runs if the form has been submitted
if (isset($_POST['submit'])) {
//This makes sure they did not leave any fields blank
if (!$_POST['username'] | !$_POST['password'] | !$_POST['pass2'] | !$_POST['email'] | !$_POST['country'] | !$_POST['nick'] ) {
die('You did not complete all of the required fields');
}
// checks if the username is in use
if (!get_magic_quotes_gpc()) {
$_POST['username'] = addslashes($_POST['username']);
}
$usercheck = $_POST['username'];
$check = mysql_query("SELECT username FROM players WHERE username = '$usercheck'")
or die(mysql_error());
$check2 = mysql_num_rows($check);
//if the name exists it gives an error
if ($check2 != 0) {
die('Sorry, the username '.$_POST['username'].' is already in use.');
}
// this makes sure both passwords entered match
if ($_POST['password'] != $_POST['pass2']) {
die('Your passwords did not match. ');
}
// here we encrypt the password and add slashes if needed
$_POST['password'] = md5($_POST['password']);
if (!get_magic_quotes_gpc()) {
$_POST['password'] = addslashes($_POST['password']);
$_POST['username'] = addslashes($_POST['username']);
}
$date = date("m/d/y");
$ip=@$REMOTE_ADDR;
// now we insert it into the database
$insert = "INSERT INTO players (ip, sponsor, username, password, nick, country, email, registered)
VALUES ($ip, $sponsor, $username, $password, $nick, $country, $email, $date)";
$add_player = mysql_query($insert);
?>
<h1>Registered</h1>
<p>Thank you, you have registered - you may now <a href=login.php>login</a>.</p>
<?php
}
else
{
?>
<form action=register.php method=post>
<table border=0>
<tr><td>Sponsor (optional):</td><td>
<input type=text name=sponsor>
</td></tr>
<tr><td>Username (what you use to login):</td><td>
<input type=text name=username>
</td></tr>
<tr><td>Nickname:</td><td>
<textarea name=nick rows=4 cols=30>Your nickname may be changed later; it may contain html and it may be the same as your username</textarea>
</td></tr>
<tr><td>Country:</td><td>
<input type=text name="country">
</td></tr>
<tr><td>E-mail Address:</td><td>
<input type=text name=email>
</td></tr>
<tr><td>Password:</td><td>
<input type=password name=password>
</td></tr>
<tr><td>Confirm Password:</td><td>
<input type=password name=pass2>
</td></tr>
<tr><th colspan=2><input type=submit name=submit value=Register></th></tr> </table>
</form>
<?php
}
?>