I'm making an online dog simulation (like furry-paws.com) and I'm new to PHP. Whenever I fill out the register form it tells me its not filled out. I also think that I did the values wrong.
Can anyone check this over and help me to fix it?
<?php
include('connect.php');
include('header.php');
if($loggedin == '1')
die("You can only have one account!");
// Register Script
if(isset($_POST['submit']))
{
// trim removes the whitespaces from the beginning and end of text
// this keeps someone from having a username of " "
$uname = trim($_POST['username']);
// Make sure all forms were filled out.
if((!isset($_POST['username'])) || (!isset($_POST['pass']))
|| ($uname == '') || ($_POST['pass'] == ''))
die("Please fill out the form completely. <br><br>
<a href=register.php>Continue</a>");
// Make sure name hasn't already been used.
$check = @mysql_query("SELECT id FROM users WHERE username = '$uname'");
$check = @mysql_num_rows($check);
if($check > 0)
die("Sorry, that username has already been taken. Please try again.
<br><br>
<a href=register.php>Continue</a>");
// Encrypt password
$pass = md5($_POST['pass']);
// Finally, create the record.
$newUser = @mysql_query("INSERT INTO users (username, password, registered, email, kennelname, firstname, lastname, gender, heard_about_site) VALUES ('$uname', '$pass', '$email', '$kennelname', '$firstname', '$lastname', '$gender', '$heard_about_site' )") or die("Error: ".mysql_error());
echo 'You have been registered! You may now <a href=index.php>Log in</a>.';
}
else
{
// form example
echo '<form action=register.php method=post>
Username: <input type=text name=username> <br><br>
Password: <input type=password name=password><br><br>
Email: <input type=text name=email><br><br>
Kennel Name: <input type=text name=kennelname><br><br>
First Name: <input type=text name=firstname><br><br>
Last Name: <input type=text name=lastname><br><br>
Gender: <input type="radio" name="gender" value="male"> Male
<input type="radio" name="gender" value="female"> Female<br><br>
How did you hear about us? <input type=text name=heard_about_site><br>
<input type=submit name=submit value=Submit>
</form>';
}
?>
<?php
include('footer.php') ?>