aty01 Posted January 29, 2013 Share Posted January 29, 2013 Hi i have a issue which i am not able to solve i am trying to insert members into an sql database via php but all i get is empty records. i get the message member inserted, but like i say in the sql all it shows is empty records the code is as follows... <html> <head> <title>Scotia Cruises registration</title> </head> <body> <h1>Customer Registration</h1> <?php $customer_id=$_POST['customer_id']; $customer_title=$_POST['customer_title']; $customer_forename=$_POST['customer_forename']; $customer_surname=strtoupper($_POST['customer_surname']); $customer_address_1=$_POST['customer_address_1']; $customer_address_2=$_POST['customer_address_2']; $customer_town=$_POST['customer_town']; $customer_postcode=$_POST['customer_postcode']; $customer_age=$_POST['customer_age']; $customer_country=$_POST['customer_country']; $customer_telephone_number=$_POST['customer_telephone_number']; $customer_email=$_POST['customer_email']; $customer_password=$_POST['customer_password']; @ $db = mysql_connect('****************************', '**********', '**********'); if (!$db) { echo 'Error: Could not connect to database. Please try again later.'; exit; } else { mysql_select_db('**********'); $query = "insert into customer(customer_id,customer_title,customer_forename,customer_surname,customer_address_1,customer_address_2,customer_town,customer_postcode,customer_age,customer_country,customer_telephone_number,customer_email,customer_password) values ('$customer_id','$customer_title','$customer_forename','$customer_surname','$customer_address_1','$customer_address_2','$customer_town','$customer_postcode','$customer_age','$customer_country','$customer_telephone_number','$customer_email','$customer_password')"; $result = mysql_query($query); if ($result) echo 'Member inserted'; else echo 'Did not work'; } ?> <p>Click <a href="manage_account.html">here</a> to return to the login page</font></p> </body> </html> Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 29, 2013 Share Posted January 29, 2013 You need to check for errors. See the link in my signature on debugging SQL. And next time, use code tags. Quote Link to comment Share on other sites More sharing options...
Barand Posted January 29, 2013 Share Posted January 29, 2013 You also need to check that the POST data exists and you are not just writing empty variables to the database table. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.