i have a little problem.
i have a contact-form and want to update my database with a crud.
My Contact-Form:
<!-- UPDATE -->
<div >
<div >
<?php
if(isset($_GET['edit'])):
$result = $crud->getMember($_GET['edit']);
?>
<hr />
<div >
<h3> UPDATE </h3>
<form method="post" action="formprocess.php" enctype="multipart/form-data">
<div >
<input type="text" name="vorname" value="<?= $result['vorname']; ?>">
</div>
<div >
<label>Foto</label>
<input type="file" name="Foto">
</div>
<div >
<input type="text" name="birthday" value="<?= $result['birthday']; ?>">
</div>
<div >
<h5> Geschlecht </h5>
<select name="Geschlecht">
<option value=""> </option>
<option value=" Männlich" <?php if($result['Geschlecht'] == 'Männlich'){ ?> selected <?php } ?>> Männlich </option>
<option value=" Weiblich" <?php if($result['Geschlecht'] == 'Weiblich'){ ?> selected <?php } ?>> Weiblich </option>
<option value="Divers" <?php if($result['Geschlecht'] == 'Divers'){ ?> selected <?php } ?>> Divers </option>
</select>
</div>
<div >
<input type="email" placeholder="[email protected]" name="email" value="<?= $result['email'];?>">
</div>
<div >
<input type="text" placeholder="01575 2234455" name="phone" value="<?= $result['phone'];?>">
</div>
<p> <input type="hidden" name="ID" value="<?= $result['ID']; ?>">
<p> <input type="submit" name="update" Value="Update"> </p>
</form>
</div>
<?php
endif;
?>
My formprocess:
if(isset($_POST['update'])) {
if(isset($_POST['vorname']) && !empty($_POST['vorname']) &&
isset($_FILES['Foto']) && !empty($_FILES['Foto']) &&
isset($_POST['Geschlecht']) && !empty($_POST['Geschlecht']) &&
isset($_POST['birthday']) && !empty($_POST['birthday']) &&
isset($_POST['phone']) && !empty($_POST['phone']) &&
isset($_POST['email']) && !empty($_POST['email']) &&
isset ($_POST['ID']) && !empty($_POST['ID'])
){
$vorname = $_POST['vorname'];
$pfad = "upload/";
$filename = $_FILES['Foto'] ['tmp_name'];
$name = $pfad . time() . "-" . $_FILES['Foto'] ['name'];
$Geschlecht = $_POST['Geschlecht'];
$birthday = $_POST ['birthday'];
$phone = $_POST ['phone'];
$email = $_POST['email'];
$ID = $_POST ['ID'];
if(move_uploaded_file($filename,$name)){
if($crud->updateMember($ID, $vorname, $name, $Geschlecht, $birthday, $phone, $email)) {
$_SESSION['msg-class'] = "success";
$_SESSION['msg'] = "Update war erfolgreich!";
header('location: Admin.php');
} else{
$_SESSION['msg-class'] = "danger";
$_SESSION['msg'] = "Es ist ein Fehler aufgetreten!";
header('location: Admin.php');
}
}
}
}
My crud.php:
public function updateMember($ID, $vorname, $Foto, $Geschlecht, $birthday, $phone, $email) {
$stmt = $this->conn->prepare("UPDATE testing SET vorname = :vorname, Foto = :Foto, Geschlecht = :Geschlecht, birthday = :birthday, phone = :phone, email = :email WHERE ID=:ID");
$erg = $stmt->execute(array(
':vorname' => $vorname,
':Foto' => $Foto,
':Geschlecht' => $Geschlecht,
':birthday' => $birthday,
':phone' => $phone,
':email:' => $email,
':ID' => $ID
));
return $erg;
If i press the Update button i get that error:
Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in C:\Xampp\htdocs\dashboard\pRAKTI\Testing 3\classes\crud.php:51 Stack trace: #0 C:\Xampp\htdocs\dashboard\pRAKTI\Testing 3\classes\crud.php(51): PDOStatement->execute(Array) #1 C:\Xampp\htdocs\dashboard\pRAKTI\Testing 3\formprocess.php(66): Crud->updateMember('12', 'Boris', 'upload/16693640...', ' Weiblich', '0000-00-01', '666', '[email protected]') #2 {main} thrown in C:\Xampp\htdocs\dashboard\pRAKTI\Testing 3\classes\crud.php on line 51
i don't know why, can anyone help?