my PHP code will NOT insert records into my SQL dabase table -


i have following php code/file on website ungodly reason not insert records typed in user mysql database table required to. can tell me why is?

so far can tell code correct don't know why happening...

please help...code below...

<html> <head> </head>  <body> <form action="register_development_file_1.php" method="post">     email:  <input type="text" name="email"><br />     date:   <input type="text" name="date"><br />     time:   <input type="text" name="time"><br />         <input type="submit" name="submit"> </form>      <?php     if  (isset($_post['submit']))     {         $con = mysql_connect("localhost","username","password");         if (!$con)         {             die("could not connect database: " . mysql_error());         }          mysql_select_db("wwwbrecs_brec",$con);     $sql = "insert 'signups' ('signup_email_address', 'signup_date', 'signup_time') values ('$_post[email]','$_post[date]','$_post[time]')";          mysql_query($sql,$con);          mysql_close($con);     }     ?> </body> </html> 

there syntax error in query, sholdn't surround table name , column quotes ' , @ least can use backtick `

insert 'signups' ('signup_email_address', 'signup_date','signup_time') 

should be

insert signups (signup_email_address, signup_date, signup _time) values  

or

insert `signups` (`signup_email_address`, `signup_date`, `signup _time`) values  

only values (actually not integers integers columns) should surrounded quotes '.

then remember mysql_ functions deprecated advise switch mysqli or pdo , indeed @ risk of sql injection, have here how can prevent sql injection in php?. should use prepared statment avoid risk


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -