better yet. tell me if there is anything wrong with this as to why it wouldn't be posting data to the database...
<?php
$submit = $_POST['submit'];
//form data
$firstname = strip_tags($_POST['firstname']);
$lastname = strtolower( strip_tags($_POST['lastname']));
$password = strip_tags($_POST['password']);
$repeatpassword = strip_tags($_POST['repeatpassword']);
$date = date("Y-m-d");
$email = strip_tags($_POST['email']);
$state = strip_tags($_POST['state']);
$school = strip_tags($_POST['school']);
if ($submit)
{
//open database
$connect = mysql_connect("localhost","USERNAME","PASSWORD")or die("Coundn't connect!");
mysql_select_db("DBNAME") or die("couldn't find db"); //select database
$namecheck = mysql_query("SELECT email FROM users WHERE email='$email'");
$count = mysql_num_rows($namecheck);
if ($count!=0)
{
die("Email already registered");
}
// email is okay
if (stristr($email, '.edu')) {
//check for existance
if ($firstname&&$lastname&&$password&&$repeatpassword&&$email&&$state&&$school)
{
if($password==$repeatpassword)
{
//check char length of lastname and firstname
if (strlen($lastname)>25||strlen($firstname)>25)
{
echo "<b>Lenth of lastname or firstname is too long</b>!";
}
else
{
//check password length
if (strlen($password)>25||strlen($password)<6)
{
echo "<b>Password must be between 6 and 25 characters</b>";
}
else
{
//register the user!
// encrypt password
$password = md5($password);
$repeatpassword = md5($repeatpassword);
//generate random number for activation process
$random = rand(23456789,98765432);
$queryreg = mysql_query("
INSERT INTO users VALUES ('','$firstname','$lastname','$password','$email','$state','$school','$date','$random','0')
");
$lastid = mysql_insert_id();
//send activation email
$to = $email;
$subject = "Activate your account!";
$headers = "From: HEADER";
$server = "localhost";
$port = "465";
$email = "EMAIL ADDRESS";
$password = "PASSWORD";
ini_set("SMTP", $server);
$body = "
Hello $firstname,\n\n
You need to activate your account with the link below:
http://www.MYWEBSITE.com/activate.php?id=$lastid&code=$random\n\n
Thanks!
";
//function to send email
mail($to, $subject, $body, $headers);
die(" <b>Thank you for registering! Please check your email to activate your account.</b>");
}
}
}
else
echo "<b>Your passwords do not match!</b>";
}
else
echo "<b>Please fill in <u>All</u> Fields!</b>";
}
else
echo "<b>You must enter your school email to register.</b>";
}
?>