I have been trying all different ideas from different threads around the internet but i cant seem to find any ideas why my form will not submit or reset the changes i have made to the data. The code works to pull the data from the data base but when i make changes the submit and reset buttons do nothing.
<?php
session_start();
//check session first
if (!isset($_SESSION['employee_id'])){
echo "You are not logged in!";
exit();
}else{
//include the header
include ("../includes/managerheader.php");
require_once ('../../mysqli_connect.php');
$customer_id=$_GET['customer_id'];
$query = "SELECT * FROM customers WHERE customer_id=$customer_id";
$result = @mysqli_query ($dbc, $query);
$num = mysqli_num_rows($result);
if ($num > 0) { // If it ran OK, display all the records.
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
?>
<form action="customerupdate2.php" method="post">
Customer ID: <input name="customer_id" size=50 value="<? echo $row['customer_id']; ?>"></br></br>
First Name: <input name="first_name" size=50 value="<? echo $row['first_name']; ?>"><p>
Last Name: <input name="last_name" size=50 value="<? echo $row['last_name']; ?>"><p>
Email Address: <input name="email" size=50 value="<? echo $row['email']; ?>"><p>
Password: <input name="password" size=50 value="<? echo $row['password']; ?>"><p>
Address: <input name="address" size=50 value="<? echo $row['address']; ?>"><p>
City: <input name="city" size=50 value="<? echo $row['city']; ?>"><p>
State: <input name="state" size=50 value="<? echo $row['state']; ?>"><p>
Zip: <input name="zip" size=50 value="<? echo $row['zip']; ?>"><p>
Telephone: <input name="telephone" size=50 value="<? echo $row['telephone']; ?>"><p>
Payment Type: <input name="payment_type" size=50 value="<? echo $row['payment_type']; ?>"><p>
Card Number: <input name="card_number" size=50 value="<? echo $row['card_number']; ?>"><p>
<input type="submit" value="update">
<input type="reset" value="reset">
<input type="hidden" name="customer_id" value="<? echo $row['customer_id']; ?>">
</form>
<?
} //end while statement
} //end if statement
mysqli_close($dbc);
//include the footer
include ("../includes/footer.php");
}
?>
The action of the form is linked to this:
<?php
session_start();
//check the session
if (!isset($_SESSION['manager'])){
echo "You are not logged in!";
exit();
}else{
//include the header
include ("../includes/managerheader.php");
require_once ('../../mysqli_connect.php');
#execute UPDATE statement
$first_name = mysqli_real_escape_string($dbc, $_POST['first_name']);
$last_name = mysqli_real_escape_string($dbc, $_POST['last_name']);
$email = mysqli_real_escape_string($dbc, $_POST['email']);
$password = mysqli_real_escape_string($dbc, $_POST['password']);
$address = mysqli_real_escape_string($dbc, $_POST['address']);
$city = mysqli_real_escape_string($dbc, $_POST['city']);
$state = mysqli_real_escape_string($dbc, $_POST['state']);
$zip = mysqli_real_escape_string($dbc, $_POST['zip']);
$telephone = mysqli_real_escape_string($dbc, $_POST['telephone']);
$payment_type = mysqli_real_escape_string($dbc, $_POST['payment_type']);
$card_number = mysqli_real_escape_string($dbc, $_POST['card_number']);
$query = "UPDATE employees SET employe_id='$employe_id',first_name='$first_name',last_name='$last_name',email='$email',
password='$password',address='$address',city='$city',state='$state',zip='$zip',
telephone='$telephone',payment_type='$payment_type',card_number='$card_number', WHERE id='$id'";
$result = @mysqli_query ($dbc, $query);
if ($result){
echo "<center><p><b>The selected customer has been updated.</b></p>";
echo "<a href=managerloggedin.php>Home</a></center>";
}else {
echo "<p>The customer could not be updated due to a system error" . mysqli_error() . "</p>";
}
mysqli_close($dbc);
//include the footer
include ("../includes/footer.php");
}
?>
` tags in your form which aren't closed anywhere...
– Johannes Aug 07 '18 at 22:59tags and still nothing. The reset doesn't return the customer data to before any changes either.
– Joe C Aug 07 '18 at 23:46