I have a simple insert page that seems to go through with out any errors but does not show up in db. I have read upwards of 30 diff posts on this and can not figure out what is wrong. I know the dbcon.php works as the display page pulls all the results no problem.
<?php
ob_start();
include('dbcon.php');
if (isset($_POST['submit'])){
$Ph1=preg_replace('/[^0-9]/', '', $_POST["ph1"]);
$Ph2=preg_replace('/[^0-9]/', '', $_POST["ph2"]);
$Name=mysql_real_escape_string($_POST['name']);
$Email=mysql_real_escape_string($_POST['email']);
$Group=$_POST['group'];
mysql_query("insert into reps (ph1,ph2,name,email,group)
values("$Ph1","$Ph2","$Name","$Email","$Group")");
header('location:index.php');
}
ob_flush();
?>
GROUPis a RESERVED KEYWORD. It must be enclosed with backtick,another problem is the used of `double quotes around values.
As a sidenote, the query is vulnerable with
SQL Injectionif the value(s) of the variables came from the outside. Please take a look at the article below to learn how to prevent from it. By usingPreparedStatementsyou can get rid of using single quotes around values.