| | |
Data not going into my database??! plz help
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2009
Posts: 2
Reputation:
Solved Threads: 0
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
________________________
_______________________
My REGISTRATION PAGE
_______________________
________________________________________
MY EMAIL ACTIVATION PAGE - activate.php that corresponds with the confirmation:
________________________________________
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
________________________
sql Syntax (Toggle Plain Text)
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 Syntax (Toggle Plain Text)
<?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 Syntax (Toggle Plain Text)
<?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!"); ?>
Last edited by peter_budo; Mar 26th, 2009 at 11:26 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Hi,
I agree with Chris... Use echo $sql_query to display if the query is working... If you are still unsure, try to use it through phpmyadmin and echo the query with values...
Secondly, when you run mysql_query, use or die with it..
E.g.:
It gives u more detail why query failed...
Thirdly, when you using auto_increment on a field, just put 0 in that filed value... mysql automatically assigns an id value to it..
Also, make sure your $id and $random values are coming correctly in the url that you giving in the activation email...
I agree with Chris... Use echo $sql_query to display if the query is working... If you are still unsure, try to use it through phpmyadmin and echo the query with values...
Secondly, when you run mysql_query, use or die with it..
E.g.:
php Syntax (Toggle Plain Text)
mysql_query($sql) or die("Query failed: ".mysql_error());
It gives u more detail why query failed...
Thirdly, when you using auto_increment on a field, just put 0 in that filed value... mysql automatically assigns an id value to it..
Also, make sure your $id and $random values are coming correctly in the url that you giving in the activation email...
Last edited by sikka_varun; Mar 25th, 2009 at 3:45 pm.
hi this is nathen,
PHP Syntax (Toggle Plain Text)
insert into cfair_deals (deal_affid, deal_storeid, deal_catid, subcat_id, deal_type, deal_title, deal_url, deal_coupon_code,deal_coupon_file,deal_start_date,deal_expire_date,deal_promotion,deal_expire,deal_barcode,deal_price,deal_oldprice,deal_discount, deal_pricecurrency,deal_oldcurrency,deal_image, deal_shortdesc,deal_fulldesc,deal_topcoupon,deal_hotweek,deal_status,added_on) VALUES ( '$aff_id', '$store_id', '$cat_id', '$categoryname', '$deal_type', '$deal_title', '$deal_url', '$coupon_code','$couponfilename','$sdate', '$edate','$promotion','$expdate','$bar_code','$price','$old_price','$discount','$price_currency','$oldprice_currency','$filename','$short_desc', '$long_desc','$top_coupon','$hot_coupon', '$status',now())
Last edited by peter_budo; Mar 26th, 2009 at 11:26 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
![]() |
Similar Threads
- import txt file sql database plz help! (C#)
- single quotes(') problem in inserting data into database (PHP)
- problem while storing the data in MS Access 2003 (VB.NET)
- How to code for a login form by taking data from Oracle db? (Visual Basic 4 / 5 / 6)
- Hi problem in database in c# plz help....? (C#)
- editing data in database using flexgrid (Visual Basic 4 / 5 / 6)
- how to insert data into the database in vb.net using textfields. (VB.NET)
- hi i have prob solve it plz (Perl)
- view and edit data from database (VB.NET)
- data access (Visual Basic 4 / 5 / 6)
Other Threads in the PHP Forum
- Previous Thread: Some URL rewrite help needed
- Next Thread: connecting fields in access via selected drop down menu
| Thread Tools | Search this Thread |
.htaccess ajax apache api array beginner binary broken buttons cakephp checkbox class cms code cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail mediawiki menu mlm mod_rewrite multiple mysql number oop paypal pdf php phpincludeissue phpmyadmin problem query radio random recursion regex remote script search server sessions sms soap source sp space speed sql subdomain syntax system table tag tutorial update upload url validation validator variable vbulletin video web websphere white xml youtube





