-2

Hii folks I need your help to solve this problem .I m a beginner in php.. I m trying to add a forms to my website (html/css) but I always get this error.. hope you'll help me Ps: when I delete the line 32 it works but my DB still empty Below is my php code.

if ( isset($_POST['Nom']) ||   isset($_POST['Prenom']) ||  isset($_POST['Numero']) ||  isset($_POST['Service'])) {
$Nom =$_POST['Nom']; 
$Prenom=$_POST['Prenom']; 
$email=$_POST['email']; 
$Numero=$_POST['Numero']; 
$groupe=$_POST['Service'];
$message=$_POST=['message'];}
if (!empty($Nom) || !empty($Prenom) ||  !empty($email) ||  !empty($Numero)  ||  !empty($Service) ||  !empty($message) )
{ $host="localhost";
 $dbUsername="root";
 $dbPassword="";
 $dbname="teknicz";
 //create connection
 $conn=new mysqli($host,$dbUsername,$dbPassword,$dbname);
 if (mysqli_connect_error()) {
 die ('Connect Error ('.mysqli_connect_errno().')'.mysqli_connect_error());}
 else { 
 $SELECT="SELECT email from registration Where email=? limit 1";
 $INSERT="INSERT Into registration(Nom,Prenom,email,Numero,Service,message)values (?,?,?,?,?,?)";
 //Prepare statement
 $stmt=$conn->prepare($SELECT);
 $stmt->bind_param("s",$email);
 $stmt->execute();
 $stmt->bind_result($email);
 $stmt->store_result();
 $rnum=$stmt->num_rows;
 if ($rnum==0) {
    $stmt->close();
    $stmt=$conn->prepare($INSERT);
    $stmt->bind_param("sssiss",$Nom,$Prenom,$email,$Numero,$Service,$message);
    $stmt->execute();
 echo"Demande Envoyée"; 
 }
else { 
echo "Email déjà utilisé";}
$stmt->close();
$conn->close();
 } 
} else {echo "Tous les champs sont nécessaires";
die();
}
?> ```

1 Answers1

-1

The line 32: $stmt->execute(); only execute the action on your db. The error is on other place.

Check if any variables on this line is an array instead of a string:

$stmt->bind_param("sssiss", $Nom, $Prenom, $email, $Numero, $Service, $message);

UPDATE:

you have an error in:

$message = $_POST = ['message'];

should be:

$message = $_POST['message'];

$message and $_POST are getting an generic array ['message'] and that is causing the error.

André Walker
  • 588
  • 10
  • 30