I don't know why this code isn't word <?php require_once('config.php'); //This code runs if the form has been submitted if (isset($_POST['cere'])) { // now we insert it into the database $insert = "INSERT INTO comment (nume, mail, comentariu) VALUES ('".$_POST['nume']."', '".$_POST['email']."', '".$_POST['comentariu']."')"; $add_member = mysql_query($insert); ?> Data has been edited <meta http-equiv='Refresh' content='2; URL=test.php'> <?php } else { ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> Numele tau*:<br /> <input type="text" name="nume" size="50" /><br /> Email-ul tau*:<br /> <input type="text" name="email" size="50" /><br /> COMENTARIU*:<br /> <TEXTAREA NAME="comentariu" COLS=60 ROWS=9></TEXTAREA><br /> *Campurile marcate cu steluta sunt obligatorii.<br /> <input id="buton" type="submit" name="cere" value="Trimite" style="margin-top:5px;"/> <input id="buton" type="reset" name="reset" value="Reseteaza" style="margin-top:5px;"/> </form> <?php } ?> PHP:
What's the error you are receiving? Is the page showing up and submitting but nothing is being placed into the database?
Yes, an error message would be great.... I've broken up your code though and tested it. Your SQL syntax seems to be ok (Just by glancing at it, i can't see an error). So my bet is on bad mysql login details, or you simply haven't setup a connection at all in your config.php file. But again, just speculation without more information on the error you're receiving.
it has no error message . it says Data has been edited but is not introducing anything in the table... i check the table name .. i check the config.php... everything is ok . but the script is not working
Also, to avoid SQL injection, you should clean up an user's input before inserting the data into your database.
Thank you guys now is working. @littlejohn199 what do you recommend for that? i really need to know how to do this.