i've got application lets select customer database , update it's information. if user doesn't enter valid email error message displayed stored in seperate php file. know how include "back" button displays page again can update customers information?
<?php include '../view/header.php'; ?> <div id="main"> <h2>view/update customer</h2> <form action="index.php" method="post" id='aligned'> <input type="hidden" name="action" value="update_customer"> <input type="hidden" name="customer_id" value="<?php echo $customer['customerid']; ?>"> <label>first name:</label> <input type="text" name="first_name" value="<?php echo $customer['firstname']; ?>"> <br> <label>last name:</label> <input type="text" name="last_name" value="<?php echo $customer['lastname']; ?>"> <br> <label>address:</label> <input type="text" name="address" value="<?php echo $customer['address']; ?>"> <br> <label>city:</label> <input type="text" name="city" value="<?php echo $customer['city']; ?>"> <br> <label>state:</label> <input type="text" name="state" value="<?php echo $customer['state']; ?>"> <br> <label>postal code:</label> <input type="text" name="postal_code" value="<?php echo $customer['postalcode']; ?>"> <br> <label>country code:</label> <input type="text" name="country_code" value="<?php echo $customer['countrycode']; ?>"> <br> <label>email:</label> <input type="text" name="email" value="<?php echo $customer['email']; ?>"> <br> <label>phone:</label> <input type="text" name="phone" value="<?php echo $customer['phone']; ?>"> <br> <label>password:</label> <input type="text" name="password" value="<?php echo $customer['password']; ?>"> <br> <label> </label> <input type="submit" value="update customer"> <br><br> <a href="?action=search_customer">search customer</a> </form>
<?php require('../model/database.php'); require('../model/customer_db.php'); $action = filter_input(input_post, 'action'); if($action == null) { $action = filter_input(input_get, 'action'); if($action == null) { $action = 'search_customer'; } } if ($action == 'search_customer') { $search = filter_input(input_post, 'search'); $results = search_customer($search); include('search_customer.php'); } else if ($action == 'select_customer') { $customer_id = filter_input(input_post, 'customer_id'); if ($customer_id == null) { $error = "wrong or missing customer id"; include ("../errors/error.php"); } else { $customer = get_customer($customer_id); include('update_customer.php'); } } else if ($action == 'update_customer') { $customer_id = filter_input(input_post, 'customer_id'); $first_name = filter_input(input_post, 'first_name'); $last_name = filter_input(input_post, 'last_name'); $address = filter_input(input_post, 'address'); $city = filter_input(input_post, 'city'); $state = filter_input(input_post, 'state'); $postal_code = filter_input(input_post, 'postal_code'); $country_code = filter_input(input_post, 'country_code'); $phone = filter_input(input_post, 'phone'); $email = filter_input(input_post, 'email', filter_validate_email); $password = filter_input(input_post, 'password'); if ($email == false) { $error = "please enter valid email"; include ("../errors/error.php"); } else { update_customer($first_name, $last_name, $address, $city, $state, $postal_code, $country_code, $phone, $email, $password, $customer_id); header("location: ."); } } ?>
and thats error file
<?php include '../view/header.php'; ?> <div id="main"> <h1 class="top">error</h1> <p><?php echo $error; ?></p> </div> <?php include '../view/footer.php'; ?>
i tried put
<a href="?action=select_customer&customer_id=$customer_id"></a>
but gives me error missing customer id.
Comments
Post a Comment