Jump to content

Recommended Posts

I am having a problem inserting information into my database.  It will not create a record, no matter what I do.  I have used the exact same template for two other pages, and it works fine, but for this one, it simply will not work.  If I echo each variable, it will print out, but even if I reduce the insert to one field, it still will not work.  Please help...  Here is my code.  

<?php
session_start();
?>

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>WO</title>
  </head>
  <body>

<?php
require('connect.php');

$ID = $_POST['ID'];
$CustomerFirstName = $_POST['Customer_B'];
$CustomerLastName = $_POST['Customer_A'];
$CustomerAddress = $_POST['Customer_C'];
$CustomerCity = $_POST['Customer_D'];
$CustomerState = $_POST['Customer_E'];
$CustomerZipCode = $_POST['Customer_F'];
$CustomerPhone = $_POST['Customer_G'];
$CustomerEmail = $_POST['Customer_H'];
$SCLastName = $_POST['Service_A'];
$SCFirstName = $_POST['Service_B'];
$SCAddress = $_POST['Service_C'];
$SCCity = $_POST['Service_D'];
$SCState = $_POST['Service_E'];
$SCZip = $_POST['Service_F'];
$SCPhone = $_POST['Service_G'];
$SCEmail = $_POST['Service_H'];
$DateRequested =  date('Y-m-d', strtotime($_POST['Date_Requested']));
$DateScheduled =  date('Y-m-d', strtotime($_POST['Date_Scheduled']));
$AssignedTo = $_POST['Assigned_To'];
$ServiceBranch = $_POST['Service_Branch'];
$Warranty =  isset($_POST['Warranty'])?$_POST['Warranty']:"No";
$WorkRequested = $_POST['Work_Requested'];


$sql = "INSERT INTO WorkOrder (ID, CustomerLastName, CustomerFirstName, CustomerAddress, CustomerCity, CustomerState, CustomerZip, CustomerPhone, CustomerEmail, SCLastName, SCFirstName, SCAddress, SCCity, SCState, SCZip, SCPhone, SCEmail, DateRequested, DateScheduled, Warranty, WorkRequested, ServiceBranch, AssignedTo) 
VALUES ('$ID', '$CustomerLastName', '$CustomerFirstName', '$CustomerAddress', '$CustomerCity', '$CustomerState', '$CustomerZipCode', '$CustomerPhone', '$CustomerEmail', '$SCLastName', '$SCFirstName', '$SCAddress', '$SCCity', '$SCState', '$SCZip', '$SCPhone', '$SCEmail', '$DateRequested', '$DateScheduled', '$Warranty', '$WorkRequested', '$ServiceBranch', '$AssignedTo')";

if ($conn->query($sql) == TRUE) {
   echo "<script type='text/javascript'> alert('Work Order Created'); </script>";
   echo "<script type='text/javascript'> document.location = 'Main.php'; </script>";
} else {
   echo "<script type='text/javascript'> alert('Record Not Inserted'); </script>";
   echo "<script type='text/javascript'> document.location = 'Work_Order.php'; </script>;
}


?>

  </body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/309715-insert-into-problems/
Share on other sites

Since you aren't giving us any error message have you looked into the error log on your system to see if any is being reported?  Do you get any message from the code that says the query did not run, or just looking at the table and not seeing your record(s)?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.