wright67uk Posted January 16, 2013 Share Posted January 16, 2013 I'm using the file below, however nothing gets added to my database. I've tested my database connection, and i've echoed $email and $name, can I put this down to incorrect syntax? <div id="form"> <form name="form1" method="post" action="form-email.php"> <input type="text" onclick="this.value=''" name="name" class="round" value="name" size="20" /> <input type="text" onclick="this.value=''" name="email" class="round" value="email" size="20"/> <input type="submit" class="round" name="Submit" value="Register Your interest"/> </form> </div> <?php if (isset($_POST['Submit'])) { if ($_POST['name'] != "") { $name = filter_var($_POST['name'], FILTER_SANITIZE_STRING); if (!filter_var($name, FILTER_SANITIZE_STRING)) { $errors .= '* Please enter a valid name.<br/><br/>'; } } else { $errors .= '* Please enter your name.<br/>'; } if ($_POST['email'] != "") { $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $errors .= "* $email is <strong>NOT</strong> a valid email address "; } } else { $errors .= '* Please enter your email address.<br/>'; } if (!$errors) { $hostname = "###"; $username = "###"; $dbname = "###"; $password = "###"; $con = mysql_connect ("$hostname", "$username", "$password"); if (!$con) { die ('Could not connect: ' . mysql_error ()); } mysql_select_db ("###", $con); $sql = "INSERT INTO NLCUP (name, email) VALUES ('$name', '$email')"; echo '<p style="color: white; margin-left:105px; font-size:22px; padding-top:15px">* Thankyou, we will be in touch soon!<br></p>'; } else { echo '<p style="color: white; margin-left:105px; padding-top:15px">' . $errors . 'please try again.</p></div>'; } } ?> </div> Link to comment https://forums.phpfreaks.com/topic/273253-no-entries-to-my-database/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 16, 2013 Share Posted January 16, 2013 Where exactly is your mysql_query statement in your code? Link to comment https://forums.phpfreaks.com/topic/273253-no-entries-to-my-database/#findComment-1406225 Share on other sites More sharing options...
Jessica Posted January 16, 2013 Share Posted January 16, 2013 Well you never try to run the query. mysql_query Awwww. Link to comment https://forums.phpfreaks.com/topic/273253-no-entries-to-my-database/#findComment-1406226 Share on other sites More sharing options...
wright67uk Posted January 16, 2013 Author Share Posted January 16, 2013 I feel very silly :-( ...and thank you for the replies. Link to comment https://forums.phpfreaks.com/topic/273253-no-entries-to-my-database/#findComment-1406242 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.