Hello,
I have a login/registration script thats altered to correspond with my database. It includes the login, logout, change password, email validation, etc. I have it setup pretty well however, when I hit submit, the information doesn't go into my database. I get the error message "Data Missing" which comes the activate.php. I check my query line over and over but I have been stuck for 3 days now. Can someone help me please? Heres the code/information:
________________________
My MYSQL DATABASE
________________________
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`first_name` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`last_name` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`address` varchar(60) COLLATE utf8_unicode_ci NOT NULL,
`city` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
`state` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
`zip_code` int(10) NOT NULL,
`birth_month` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`birth_day` varchar(2) COLLATE utf8_unicode_ci NOT NULL,
`birth_year` varchar(4) COLLATE utf8_unicode_ci NOT NULL,
`phone` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(75) COLLATE utf8_unicode_ci NOT NULL,
`username` varchar(25) COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(25) COLLATE utf8_unicode_ci NOT NULL,
`security_question` varchar(60) COLLATE utf8_unicode_ci NOT NULL,
`security_answer` varchar(60) COLLATE utf8_unicode_ci NOT NULL,
`stage_name` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
`ad_phone` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`ad_phone2` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`gender` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`sexuality` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
`age` int(3) NOT NULL,
`height` varchar(5) COLLATE utf8_unicode_ci NOT NULL,
`weight` varchar(8) COLLATE utf8_unicode_ci NOT NULL,
`hair` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
`eye` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
`ethnicity` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
`available` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
`ad_location` varchar(60) COLLATE utf8_unicode_ci NOT NULL,
`ad_type` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`call_type` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`website` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`introduction` longtext COLLATE utf8_unicode_ci NOT NULL,
`comments` longtext COLLATE utf8_unicode_ci NOT NULL,
`date` date NOT NULL,
`random` int(20) NOT NULL,
`activated` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=2 ;
_______________________
My REGISTRATION PAGE
_______________________
<?php
echo "<h1>Register</h1>";
$submit = $_POST['submit'];
//form data
$firstname = strip_tags($_POST['first_name']);
$lastname = strip_tags($_POST['last_name']);
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zipcode = $_POST['zip_code'];
$birthmonth = $_POST['birth_month'];
$birthday = $_POST['birth_day'];
$birthyear = $_POST['birth_year'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$username = strtolower(strip_tags($_POST['username']));
$password = strip_tags($_POST['password']);
$repeatpassword = strip_tags($_POST['repeatpassword']);
$securityquestion = $_POST['security_question'];
$securityanswer = $_POST['security_answer'];
$stagename = strip_tags($_POST['stage_name']);
$adphone = $_POST['ad_phone'];
$adphone2 = $_POST['ad_phone2'];
$gender = $_POST['gender'];
$sexuality = $_POST['sexuality'];
$age = $_POST['age'];
$height = $_POST['height'];
$weight = $_POST['weight'];
$hair = $_POST['hair'];
$eye = $_POST['eye'];
$ethnicity = $_POST['ethnicity'];
$available = $_POST['available'];
$adlocation = $_POST['ad_location'];
$adtype = $_POST['ad_type'];
$calltype = $_POST['call_type'];
$website = $_POST['website'];
$introduction = strip_tags($_POST['introduction']);
$comments = strip_tags($_POST['comments']);
$date = date("Y-m-d");
if ($submit)
{
//open database
$connect = mysql_connect("localhost","un","pass");
mysql_select_db("db"); //select database
$namecheck = mysql_query("SELECT username FROM users WHERE username='$username'");
$count = mysql_num_rows($namecheck);
if ($count!=0)
{
die("Username already taken!");
}
//check for existance
if ($firstname&&$lastname&&$address&&$city&&$state&&$zip_code&&$birthmonth&&
$birthday&&$birthyear&&$phone&&$email&&$username&&$password&&$repeatpassword&&
$securityquestion&&$security_answer&&$stagename&&$adphone&&$adphone2&&$gender&&
$sexuality&&$age&&$height&&$weight&&$hair&&$eye&&$ethnicity&&$available&&
$adlocation&&$adtype&&$calltype&&$website&&$introduction)
{
if ($password==$repeatpassword)
{
//check char length of username
if (strlen($username)>25)
{
echo "Length of username is too long!";
}
else
{
//check password length
if (strlen($password)>25¦¦strlen($password)<6)
{
echo "Password must be between 6 and 25 characters";
}
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','$address','$city','$state','$zipcode','$birthmonth',
'$birthday','$birthyear','$phone','$email','$username','$password',
'$securityquestion','$securityanswer','$stagename','$adphone','$adphone2',
'$gender','$sexuality','$age','$height','$weight','$hair','$eye','$ethnicity',
'$available','$adlocation','$adtype','$calltype','$website','$introduction',
'$comments','$date','$random','0')");
$lastid = mysql_insert_id();
//send activation email
$to = $email;
$subject = "Activate your account!";
$headers = "From: [email]support@mysite.net[/email]";
$server = "mail.mysite.net";
ini_set("SMTP",$server);
$body = "
Hello $first_name $last_name,\n\n
You need to activate your account with the link below:
http://www.mysite.net/register/activate.php?id=$lastid&code=$random\n\n
Thanks!
";
//function to send email
mail($to, $subject, $body, $headers);
die("You have been registered! Check your email to activate your account!");
}
}
}
else
echo "Your passwords do not match!";
}
else
echo "Please fill in <b>all</b> fields!";
}
?>
________________________________________
MY EMAIL ACTIVATION PAGE - activate.php that corresponds with the confirmation:
________________________________________
<?php
$connect = mysql_connect("localhost","un","pass") or die("Couldn't connect!");
mysql_select_db("db") or die("Couldn't find db");
$id = $_GET['id'];
$code = $_GET['code'];
if ($id&&$code)
{
$check = mysql_query("SELECT * FROM users WHERE id='$id' AND random='$code'");
$checknum = mysql_num_rows($check);
if ($checknum==1)
{
//run a query to activate the account
$acti = mysql_query("UPDATE users SET activated='1' WHERE id='$id'");
die("Your account is activated. You may now log in.");
}
else
die("Invalid ID or Activation code.");
}
else
die("Data missing!");
?>