chris_161 Posted February 16, 2011 Share Posted February 16, 2011 Hi there I would be most grateful is someone could tell me why my data is not being entered into my database and not responding with an email confirmation link. Thanks in advance. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <? include('config.php'); // table name $tbl_name="temp_members_db"; // Random confirmation code $confirm_code=md5(uniqid(rand())); // values sent from form $name=$_POST['name']; $email=$_POST['email']; $country=$_POST['country']; // Insert data into database $sql="INSERT INTO $tbl_name(confirm_code,name,email,password,country) VALUES('$confirm_code','$name','$email','$password','$country')"; $result=mysql_query($sql); // if suceesfully inserted data into database, send confirmation link to email if($result){ // ---------------- SEND MAIL FORM ---------------- // send e-mail to ... $to=$email; // Your subject $subject="Your confirmation link here"; // From $header="from: your name <your email>"; // Your message $message="Your Comfirmation link \r\n"; $message.="Click on this link to activate your account \r\n"; $message.="http://www.yourweb.com/confirmation.php?passkey=$confirm_code"; // send email $sentmail = mail($to,$subject,$message,$header); } // if not found else { echo "Not found your email in our database"; } // if your email succesfully sent if($sentmail){ echo "Your Confirmation link Has Been Sent To Your Email Address."; } else { echo "Cannot send Confirmation link to your e-mail address"; } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/227868-information-not-registering-in-sql-database/ Share on other sites More sharing options...
BlueSkyIS Posted February 16, 2011 Share Posted February 16, 2011 is the query executing successfully? update to find out: $result=mysql_query($sql) or die(mysql_error() . " IN $sql"); Quote Link to comment https://forums.phpfreaks.com/topic/227868-information-not-registering-in-sql-database/#findComment-1175011 Share on other sites More sharing options...
BlueSkyIS Posted February 16, 2011 Share Posted February 16, 2011 ALSO: Do not use short PHP tags, update <? to <?php Quote Link to comment https://forums.phpfreaks.com/topic/227868-information-not-registering-in-sql-database/#findComment-1175012 Share on other sites More sharing options...
chris_161 Posted February 16, 2011 Author Share Posted February 16, 2011 That does not work either Quote Link to comment https://forums.phpfreaks.com/topic/227868-information-not-registering-in-sql-database/#findComment-1175014 Share on other sites More sharing options...
Pikachu2000 Posted February 16, 2011 Share Posted February 16, 2011 What about it 'does not work'? Are you getting any error messages? What does happen when you run the script? 'That does not work' isn't really much help. Quote Link to comment https://forums.phpfreaks.com/topic/227868-information-not-registering-in-sql-database/#findComment-1175016 Share on other sites More sharing options...
chris_161 Posted February 21, 2011 Author Share Posted February 21, 2011 It just shows a blank page with no confirmation link present and the users details does not get processed into the database. Quote Link to comment https://forums.phpfreaks.com/topic/227868-information-not-registering-in-sql-database/#findComment-1177513 Share on other sites More sharing options...
harristweed Posted February 21, 2011 Share Posted February 21, 2011 if still getting blank page must likely cause is error in include file. Comment it out and if you now get an error message check the include file! //include('config.php'); Quote Link to comment https://forums.phpfreaks.com/topic/227868-information-not-registering-in-sql-database/#findComment-1177518 Share on other sites More sharing options...
chris_161 Posted February 21, 2011 Author Share Posted February 21, 2011 Blanked out the include config file but i still just get a blank page it seems that its having the problem of putting the data into the database Quote Link to comment https://forums.phpfreaks.com/topic/227868-information-not-registering-in-sql-database/#findComment-1177561 Share on other sites More sharing options...
Muddy_Funster Posted February 21, 2011 Share Posted February 21, 2011 change this line $result=mysql_query($sql); to read $result=mysql_query($sql) or die ('ERROR in posting to database -- '.mysql_error()); and see what happens. Quote Link to comment https://forums.phpfreaks.com/topic/227868-information-not-registering-in-sql-database/#findComment-1177564 Share on other sites More sharing options...
kickstart Posted February 21, 2011 Share Posted February 21, 2011 Hi You can't really just blank out the include. Suspect that is what is connecting to the database so without that the insert will not work. However when you say you get a blank page, is it fully blank? When the page comes up do a view source and check that the html header section of the page is there. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/227868-information-not-registering-in-sql-database/#findComment-1177566 Share on other sites More sharing options...
chris_161 Posted February 21, 2011 Author Share Posted February 21, 2011 Ive changed the piece of code which muddy_funster informed me to do but now it just displays all my php code on the page, whilst before i edited the code it was just a full blank page with nothing at all on it. Quote Link to comment https://forums.phpfreaks.com/topic/227868-information-not-registering-in-sql-database/#findComment-1177570 Share on other sites More sharing options...
kickstart Posted February 21, 2011 Share Posted February 21, 2011 Hi It shouldn't do. Suggests that you have edited something else by mistake so it doesn't think it is php. Can you post your full code again with the changes in it. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/227868-information-not-registering-in-sql-database/#findComment-1177575 Share on other sites More sharing options...
chris_161 Posted February 21, 2011 Author Share Posted February 21, 2011 include('config.php'); // table name $tbl_name="temp_members_db"; // Random confirmation code $confirm_code=md5(uniqid(rand())); // values sent from form $name=$_POST['name']; $email=$_POST['email']; $country=$_POST['country']; // Insert data into database $sql="INSERT INTO $tbl_name(confirm_code, name, email, password, country)VALUES('$confirm_code', '$name', '$email', '$password', '$country')"; $result=mysql_query($sql) or die ('ERROR in posting to database -- '.mysql_error()); // if suceesfully inserted data into database, send confirmation link to email if($result){ // ---------------- SEND MAIL FORM ---------------- // send e-mail to ... $to=$email; // Your subject $subject="Your confirmation link here"; // From $header="from: your name <your email>"; // Your message $message="Your Comfirmation link \r\n"; $message.="Click on this link to activate your account \r\n"; $message.="http://www.yourweb.com/confirmation.php?passkey=$confirm_code"; // send email $sentmail = mail($to,$subject,$message,$header); } // if not found else { echo "Not found your email in our database"; } // if your email succesfully sent if($sentmail){ echo "Your Confirmation link Has Been Sent To Your Email Address."; } else { echo "Cannot send Confirmation link to your e-mail address"; } Quote Link to comment https://forums.phpfreaks.com/topic/227868-information-not-registering-in-sql-database/#findComment-1177578 Share on other sites More sharing options...
kickstart Posted February 21, 2011 Share Posted February 21, 2011 Hi Is that all of it? Have you removed the <?php and ?> start and end tags? All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/227868-information-not-registering-in-sql-database/#findComment-1177583 Share on other sites More sharing options...
chris_161 Posted February 21, 2011 Author Share Posted February 21, 2011 oh sorry that must not have copied across. I do have them in my php code. All that displays is the header saying untitled document but like i said rest of the page is blank Quote Link to comment https://forums.phpfreaks.com/topic/227868-information-not-registering-in-sql-database/#findComment-1177585 Share on other sites More sharing options...
kickstart Posted February 21, 2011 Share Posted February 21, 2011 Hi Can't see anything obvious at all. In your code just before your include put the following line error_reporting(E_ALL); That will turn on all error reporting. Just in case than error reporting from php is being suppressed. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/227868-information-not-registering-in-sql-database/#findComment-1177588 Share on other sites More sharing options...
chris_161 Posted February 21, 2011 Author Share Posted February 21, 2011 I now have now got the data entered into the database but now I get an error message on the page saying "Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\signup_ac.php on line 46 Cannot send Confirmation link to your e-mail address" Quote Link to comment https://forums.phpfreaks.com/topic/227868-information-not-registering-in-sql-database/#findComment-1177589 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.