i can't insert a new value to my DB after checking if it is existed in the DB or not the update work fine but the insert doesn't work just i wanna know where i'm wrong here to learn any help ?
<?php
mysql_connect("localhost", "root", "");
mysql_select_db("alimcenter");
$P1=$_POST['p1'];
$P2=$_POST['p2'];
$P3=$_POST['p3'];
$P4=$_POST['p4'];
$P5=$_POST['p5'];
$P6=$_POST['p6'];
$P7=$_POST['p7'];
$P8=$_POST['p8'];
$P9=$_POST['p9'];
$req1=mysql_query("select REF from mat where REF='$P1'");
if(mysql_num_rows($req1) != 0){
$req2=mysql_query("UPDATE mat set qte=qte+$P3 where REF='$P1'");
if($req2){
echo "succes update";
}
}
if(mysql_num_rows($req1) == 0){
$req7=mysql_query("insert into mat
(REF, designation, qte, un, PU, rem,
MONTANT, tva, puf)
values ('$P1', '$P2', '$P3', '$P4', '$P5', '$P6',
'$P7', '$P8', '$P9')");
mysql_error();
if($req7){
echo "succes";
echo "<br /><a href='ajout.html'>return</a>";
}
}
?>
it just display to me the button but when i check my DB i can't find the new values insert