Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (isset($_POST['create'])) {
- include "../db_conn.php";
- function validate($data){
- $data = trim($data);
- $data = stripslashes($data);
- $data = htmlspecialchars($data);
- return $data;
- }
- $customer_name = validate($_POST['customer_name']);
- $customer_email = validate($_POST['customer_email']);
- $customer_mobile = validate($_POST['customer_mobile']);
- $poNum = validate($_POST['poNum']);
- $site_name = validate($_POST['site_name']);
- $street1 = validate($_POST['street1']);
- $user_data = 'customer_name='.$customer_name.
- '&customer_email='.$customer_email.
- '&customer_mobile='.$customer_mobile.
- '&poNum='.$poNum.
- '&site_name='.$site_name.
- '&street1='.$street1;
- if (empty($customer_name)) {
- header("Location: ../index.php?error=Name is required&$user_data");
- }else if (empty($customer_email)) {
- header("Location: ../index.php?error=Email is required&$user_data");
- }else if (empty($customer_mobile)) {
- header("Location: ../index.php?error=Mobile is required&$user_data");
- }else if (empty($poNum)) {
- header("Location: ../index.php?error=PO Num is required&$user_data");
- }else if (empty($site_name)) {
- header("Location: ../index.php?error=Site Name is required&$user_data");
- }else if (empty($street1)) {
- header("Location: ../index.php?error=Address is required&$user_data");
- }else {
- $sql = "INSERT INTO users(customer_name, customer_email, customer_mobile, poNum, site_name, street1)
- VALUES('$customer_name', '$customer_email', '$customer_mobile',
- '$poNum', '$site_name', '$street1')";
- $result = mysqli_query($conn, $sql);
- if ($result) {
- header("Location: ../read.php?success=Successfully Created");
- }else {
- header("Location: ../index.php?error=Unknown error occurred&$user_data");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment