I need help with this form everytime I submit a new name to be added to the data base it refreshes the page and clears the form I think my problem is on the mysql hope some one can help.
<?php session_start(); if (!isset($_SESSION["manager"])) { header("location: admin_login.php"); exit(); } // Be sure to check that this manager SESSION value is in fact in the database // $managerID = preg_replace('#[^0-9]#i', '', $_SESSION["id"]); // filter everything but numbers and letters // $manager = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["manager"]); // filter everything but numbers and letters // $password = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["password"]); // filter everything but numbers and letters // Run mySQL query to be sure that this person is an admin and that their password session var equals the database information // Connect to the MySQL database include "../storescripts/connect_to_mysql2.php"; // $sql = mysql_query("SELECT * FROM admin WHERE id='$managerID' AND username='$manager' AND password='$password' LIMIT 1"); // query the person // ------- MAKE SURE PERSON EXISTS IN DATABASE --------- // $existCount = mysql_num_rows($sql); // count the row nums // if ($existCount == 0) { // evaluate the count // echo "Your login session data is not on record in the database."; // exit(); // } // Error Reporting error_reporting(E_ALL); ini_set('display_errors', '1'); ?> <?php // Parse the form data and add customer to the system if (isset($_POST['customer_name']) && isset($_POST['address']) && isset($_POST['city'])&& isset($_POST['state'])&& isset($_POST['zip_code']) && isset($_POST['phone_number']) && isset($_POST['email'])&& isset($_POST['order_number'])&& isset($_POST['order_date'])&& isset($_POST['medication'])&& isset($_POST['comment_box'])&& isset($_POST['extra'])){ $customer_name= mysql_real_escape_string($_POST['customer_name']); $address = mysql_real_escape_string($_POST['address']); $city = mysql_real_escape_string($_POST['city']); $state = mysql_real_escape_string($_POST['state']); $zip_code = mysql_real_escape_string($_POST['zip_code']); $phone_number = mysql_real_escape_string($_POST['phone_number']); $email = mysql_real_escape_string($_POST['email']); $order_number = mysql_real_escape_string($_POST['order_number']); $order_date = mysql_real_escape_string($_POST['order_date']); $medication = mysql_real_escape_string($_POST['medication']); $comment_box = mysql_real_escape_string($_POST['comment_box']); $extra = mysql_real_escape_string($_POST['extra']); //See if that customer name is an identical match to another customer in the system $sql = mysql_query("SELECT customer_name, COUNT(customer_name) AS NumOccurrences FROM cpanel GROUP BY customer_name HAVING ( COUNT(customer_name) > 1 )"); $customerMatch = mysql_num_rows($sql); // count the output amount if ($customerMatch > 0) { echo 'Sorry you tried to place a duplicate "Customer Name" into the system, Click Here'; exit(); } // Add new customer into the database now $sql = mysql_query("INSERT INTO cpanel (customer_name, address, city, state, zip_code, phone_number, email, order_number, order_date, medication, comment_box, extra, date_added) VALUES('$customer_name','$address','$city','$state','$zip_code','$phone_number','$email',$order_number','$order_date','$medication','$comment_box','$extra',now())") or die (mysql_error()); //$cid = mysql_insert_id(); header("location: customer_list.php"); exit(); } ?> <?php // This block grabs the whole list for viewing $customer_list =""; $sql = mysql_query("SELECT * FROM `cpanel` ORDER BY `customer_name` DESC LIMIT 0, 30"); $customerCount = mysql_num_rows($sql); // count the output amount if ($customerCount > 1) { while($row = mysql_fetch_array($sql)){ $id = $row["id"]; $customer_name = $row["customer_name"]; $address = $row["address"]; $city = $row["city"]; $state = $row["state"]; $zip_code = $row["zip code"]; $phone_number = $row["phone number"]; $email = $row["email"]; $order_number = $row["order number"]; $order_date = $row["order date"]; $medication = $row["medication"]; $comment_box = $row["comment box"]; $extra = $row["extra"]; $customer_list .= "customer ID: $id - $customer_name - $medication - $phone_number - $order_date"; } } else { $customer_list = "You have no customer yet"; } ?> Customer List
Logout
Customer List
<?php echo $customer_list; ?>↓ Add New Customer ↓
Customer Name | |
Address | |
City | |
State | |
Zip Code | |
Phone Number | |
Order Number | |
Order Date |
class="hideDropDown moduleDrop">Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
Month
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Day
2 am
3 am
4 am
5 am
6 am
7 am
8 am
9 am
10 am
11 am
12 pm
1 pm
2 pm
3 pm
4 pm
5 pm
6 pm
7 pm
8 pm
9 pm
10 pm
11 pm
12 am
|
Medication | |
Comment Box | |
Extra |