I have a problem with updating value with PHP, it can get the data that I input but it cannot update it and render it to the read page.
<?php
require_once("session.php");
require_once("included_functions.php");
require_once("database.php");
new_header("VinceT");
$mysqli = Database::dbConnect();
$mysqli->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if (($output = message()) !== null) {
echo $output;
}
echo "<h3>Update A Order</h3>";
echo "<div class='row'>";
echo "<label for='left-label' class='left inline'>";
if (isset($_POST["submit"])) {
$stmt = $mysqli->prepare("UPDATE VTCustomer SET CustomerFName=? WHERE CustomerID=?");
$stmt->execute([$_POST["CustomerFName"],$_POST["CustomerID"]]);
$stmt1 = $mysqli->prepare("UPDATE VTCustomer SET CustomerLName=? WHERE CustomerID=?");
$stmt1->execute([$_POST["CustomerLName"],$_POST["CustomerID"]]);
if($stmt) {
$_SESSION["message"] = $_POST["CustomerFName"]." has been updated";
} else {
$_SESSION["message"] = "Error! Could not update ".$_POST["CustomerFName"];
}
redirect("read.php");
} else {
if (isset($_GET["id"]) && $_GET["id"] !== "") {
$stmt = $mysqli->prepare("SELECT OrderID FROM OrderVinceT WHERE OrderID=?");
$stmt->execute([$_GET["id"]]);
if ($stmt) {
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo "<h3>Order ".$row["OrderID"]." Information</h3>";
}
echo "<form method='POST' action='update.php'>";
echo "<input type = 'hidden' name = 'OrderID' value = ' ".$row['OrderID']." ' />";
$stmt1 = $mysqli->prepare("SELECT CustomerFName FROM VTCustomer WHERE CustomerID=?");
$stmt1->execute([$_GET["id"]]);
if ($stmt1) {
while ($row1 =$stmt1 -> fetch(PDO::FETCH_ASSOC)) {
echo "<p>Customer First Name: <input type='text' name='CustomerFName' value='".$row1["CustomerFName"]."'></p>";
}
}
$stmt5 = $mysqli->prepare("SELECT CustomerLName FROM VTCustomer NATURAL JOIN OrderVinceT WHERE OrderVinceT.CustomerID=?");
$stmt5->execute([$_GET["id"]]);
if ($stmt5) {
while ($row5 =$stmt5 -> fetch(PDO::FETCH_ASSOC)) {
echo "<p>Customer Last Name: <input type='text' name='CustomerLName' value='".$row5["CustomerLName"]."'></p>";
}
}
echo "<input type='submit' name='submit' value='Update Order' class='tiny round button'/>";
echo "</form>";
echo "<br /><p>«:<a href='read.php'>Back to Main Page</a>";
echo "</label>";
echo "</div>";
} else {
$_SESSION["message"] = "Order could not be found!";
redirect("read.php");
}
}
}
new_footer("VinceT");
Database::dbDisconnect($mysqli);
?>
Do you guys have any idia why I cannot update this? I test queries in the console and it works just fine. The if statement that render out the message still receive the value of the input but it cannot update the database that render out in read.php
Related
I have tried everything I can find to try and get time formatted results from my table using mysql_fetch_array while also getting other results.
This is my code:
<?php
$con = new mysqli("mysql.hostinger.co.uk", "user", "password", "database");
$con->set_charset('utf8mb4');
//Retrieve all the data from the Update Log Table
$result = $con->query("SELECT requestID, songTitle, artistName, requester, dedicatedTo, TIME_FORMAT(requestTime, '%r'), dance FROM `table` ORDER BY requestID DESC") or die(mysql_error());
echo "<form class='formleft'>";
//keeps getting the next row until there are no more to get
while($row = mysqli_fetch_array($result)){
//Print out the contents of each row into a table
echo "<div class='reqgap'></div>";
echo "<input type='checkbox' id='play";
echo $row['requestID'];
echo "' class='play checkbox' autocomplete='off' ";
if ($row['requestID'] == '0') {
echo "style='display:none;' />";
} else {
echo "/>";
};
echo "<label class='played' for='play";
echo $row['requestID'];
echo "' ";
if ($row['requestID'] == '0') {
echo "hidden >";
} else {
echo ">";
};
echo "Played";
echo "</label>";
echo "<article class='request songs req";
echo $row['requestID'];
if ($row['requestID'] % 2 == 0) {
echo " even";
} else {
echo " odd";
};
echo "' >";
echo "<article class='requestleft'>";
echo "<article class='requestnum'>";
echo "<p class='requestnumt'>";
if ($row['requestID'] == '') {
echo "RequestID Error";
} else {
echo $row['requestID'];
}
echo "</p>";
echo"</article>";
echo "<article class='requesttime'>";
echo "<p class='requesttimet'>";
if ($row['requestTime'] == '') {
echo "Request Time Error";
} else {
echo $row['requestTime'];
}
echo " UTC</p>";
echo"</article>";
It just shows my error message "Request Time Error" when it comes to displaying that data.
Any assistance will be greatly appreciated
How do I delete one single row with the code that I have. It allows me to delete all rows instead of one single row with an ID not sure what im doing wrong not sure if its the loop I have or what.
<?php
include_once('dbconnect.php');
echo "<form action='delete.php' method='post' id = 'deleteForm'>";
$sqlARTICLEQuery = "SELECT * FROM articles where pageId=$paqueryRow[pageId] order by articleId";
$articlequeryResult = mysqli_query($conn,$sqlARTICLEQuery);
while ($articlequeryRow = mysqli_fetch_assoc($articlequeryResult))
{ echo "<input type = 'radio' name = '$articlequeryRow[articleId]' method = 'post'>".$articlequeryRow['articleId']." ".$articlequeryRow['articleTitle']." ";
echo "<input name='ARTSubmit' type='submit' value='delete record' /><br/>";
if (isset($_POST['ARTSubmit'])){
$artDeleteQuery = "DELETE FROM articles where pageId = $paqueryRow[pageId] AND articleId=$articlequeryRow[articleId].";
if(mysqli_query($conn, $artDeleteQuery)){
echo "Record deleted successfully";
} else {
echo "Error deleting record: " . mysqli_error ($conn);
}
}
$sqlTEXTQuery = "SELECT * FROM text where articleId=$articlequeryRow[articleId] order by textId";
$textqueryResult = mysqli_query($conn,$sqlTEXTQuery);
while ($textqueryRow = mysqli_fetch_assoc($textqueryResult))
{
echo "<input type = 'radio' name = '$textqueryRow[textId]' method = 'post'>".$textqueryRow['textId']." ".$textqueryRow['textTitle']." "; //how can I print articles.pageId to match with pages.pageId
echo "<input name='TEXTSubmit' type='submit' value='delete record' /><br/>";
if (isset($_POST['TEXTSubmit'])){
$textDeleteQuery = "DELETE FROM text where articleId = $articlequeryRow[articleId] AND textId = $textqueryRow[textId].";
if(mysqli_query($conn, $textDeleteQuery)){
echo "Record deleted successfully";
} else {
echo "Error deleting record: " . mysqli_error ($conn);
}
}echo "<br />"
}echo "<br />"
}echo "</form>"
$conn->close();
?>
You forgot a end quote on line 2 from the echo. and i removed the dot behind you query on line 20 your delete line. hope it helps.
include_once('dbconnect.php');
echo "<form action='delete.php' method='post' id = 'deleteForm'>";
$sqlARTICLEQuery = "SELECT * FROM articles where pageId=$paqueryRow[pageId] order by articleId";
$articlequeryResult = mysqli_query($conn,$sqlARTICLEQuery);
while ($articlequeryRow = mysqli_fetch_assoc($articlequeryResult))
{ echo "<input type = 'radio' name = '$articlequeryRow[articleId]' method = 'post'>".$articlequeryRow['articleId']." ".$articlequeryRow['articleTitle']." ";
echo "<input name='ARTSubmit' type='submit' value='delete record' /><br/>";
if (isset($_POST['ARTSubmit'])){
$artDeleteQuery = "DELETE FROM articles where pageId = $paqueryRow[pageId] AND articleId=$articlequeryRow[articleId].";
if(mysqli_query($conn, $artDeleteQuery)){
echo "Record deleted successfully";
} else {
echo "Error deleting record: " . mysqli_error ($conn);
}
}
$sqlTEXTQuery = "SELECT * FROM text where articleId=$articlequeryRow[articleId] order by textId";
$textqueryResult = mysqli_query($conn,$sqlTEXTQuery);
while ($textqueryRow = mysqli_fetch_assoc($textqueryResult))
{
echo "<input type = 'radio' name = '$textqueryRow[textId]' method = 'post'>".$textqueryRow['textId']." ".$textqueryRow['textTitle']." "; //how can I print articles.pageId to match with pages.pageId
echo "<input name='TEXTSubmit' type='submit' value='delete record' /><br/>";
if (isset($_POST['TEXTSubmit'])){
$textDeleteQuery = "DELETE FROM text where articleId = $articlequeryRow[articleId] AND textId = $textqueryRow[textId].";
if(mysqli_query($conn, $textDeleteQuery)){
echo "Record deleted successfully";
} else {
echo "Error deleting record: " . mysqli_error ($conn);
}
}echo "<br />"
}echo "<br />"
}echo "</form>"
$conn->close();
?>
I have a problem where i cant delete a row in the table i have. When i select something and click on delete, nothing happends its just refresh the page and i can select again, but the row is still there. I use the code on this page: index.php?page=Delete
Below is my code:
try{
if($DBH == null)
$DBH = new PDO($dsn, $dbuser, $dbpass);
}
catch (PDOException $e){
echo '<b>PDOException: </b>',$e->getMessage();
die();
}
$action = empty($_GET['']) ? "" : $_GET[''];
if ($action == "") # No action specified so show the home page
{
try{
$sql = "select id, name, price from goods";
$STH = $DBH->query($sql);
$STH->setFetchMode(PDO::FETCH_ASSOC);
echo "<form method='post' >";
echo "<table border='1'>";
echo "<tr><th>Name</th><th>Price</th><th>Select</th></tr>";
while ($row = $STH->fetch())
{
echo "<tr><td><br>{$row["name"]} {$row["price"]} </td>";
echo "<td>";
echo "<input type='radio' value='{$row["id"]}' name='id2edit'>";
echo "</td></tr>";
}
echo "</table>";
echo "<br>";
echo "<input type='submit' value='Delete selected product' name='button'>";
echo "</form>";
$DBH = null;
}
catch (PDOException $e){
echo '<b>PDOException: </b>',$e->getMessage();
die();
}
}
else if ($action == "action='index.php?page=Delete'")
{
$id2edit = empty($_POST["id2edit"]) ? "" : $_POST["id2edit"];
if ($id2edit == "")
{
$m = "No goods selected! To return to the home ";
$m .= "screen click <a href='delcust.php'>here.</a>";
show_message($m);
}
else
{
try{
$STH = $DBH->prepare('delete from goods where id = :id');
$STH->bindParam(':id', $id2edit);
$STH->execute();
$DBH = null;
}
catch (PDOException $e){
echo '<b>PDOException: </b>',$e->getMessage();
die();
}
}
}
I have come further now but still the value in teh table is not deleted: here is the code i have right now:
try{
# a DB Handler to manage the database connection
if($DBH == null)
$DBH = new PDO($dsn, $dbuser, $dbpass);
}
catch (PDOException $e){
echo '<b>PDOException: </b>',$e->getMessage();
die();
}
$action = empty($_GET['action']) ? "" : $_GET['action'];
if($action == "Delete"){
try{
$sql = "select id, name, price from goods";
$STH = $DBH->query($sql);
$STH->setFetchMode(PDO::FETCH_ASSOC);
echo "<form method='post' action='delcust.php?action=delete_record'>";
echo "<table border='1'>";
echo "<tr><th>Name</th><th>Price</th><th>Select</th></tr>";
while ($row = $STH->fetch())
{
echo "<tr><td><br>{$row["name"]} </td> <td> {$row["price"]} </td>";
echo "<td>";
echo "<input type='radio' value='{$row["id"]}' name='id2edit'>";
echo "</td></tr>";
}
echo "</table>";
echo "<br>";
echo "<input type='submit' value='Delete selected product' name='button'>";
echo "</form>";
$DBH = null;
}
catch (PDOException $e){
echo '<b>PDOException: </b>',$e->getMessage();
die();
}
}
else if ($action == "delete_record")
{
include("header.php");
include("nav.php");
include("aside.php");
$id2edit = empty($_POST["id2edit"]) ? "" : $_POST["id2edit"];
if ($id2edit == "")
{
$m = "No goods selected so far! Please select";
echo("$m");
}
else {
try{
$STH = $DBH->prepare('delete from goods where id = :id');
$STH->bindParam(':id', $id2edit);
$STH->execute();
echo "Goods with ID $id2edit deleted. :id To return to the home ";
echo "screen click <a href='index.php'>here.</a>";
$DBH = null;
}
catch (PDOException $e){
echo '<b>PDOException: </b>',$e->getMessage();
die();
}
include("footer.php");
}
}
?>
Problem solved:
$sql = "delete from goods where id = :id";
$STH = $DBH->prepare($sql);
now it works do delete values.
if ($action == "") is always true as $_GET[''] is always undefined(and return NULL) and empty($_GET['']) is always true.
Try below code:
try {
if ($DBH == null)
$DBH = new PDO($dsn, $dbuser, $dbpass);
} catch (PDOException $e) {
echo '<b>PDOException: </b>', $e->getMessage();
die();
}
$action = isset($_GET['page']) ? $_GET['page'] : '' ; // MODIFIED
if ($action == "Delete") { // MODIFIED
$id2edit = empty($_POST["id2edit"]) ? "" : $_POST["id2edit"];
if ($id2edit == "") {
$m = "No goods selected! To return to the home ";
$m .= "screen click <a href='delcust.php'>here.</a>";
show_message($m);
} else {
try {
$STH = $DBH->prepare('delete from goods where id = :id');
$STH->bindParam(':id', $id2edit);
$STH->execute();
} catch (PDOException $e) {
echo '<b>PDOException: </b>', $e->getMessage();
die();
}
}
}
try {
$sql = "select id, name, price from goods";
$STH = $DBH->query($sql);
$STH->setFetchMode(PDO::FETCH_ASSOC);
echo "<form method='post' >";
echo "<table border='1'>";
echo "<tr><th>Name</th><th>Price</th><th>Select</th></tr>";
while ($row = $STH->fetch()) {
echo "<tr><td><br>{$row["name"]} {$row["price"]} </td>";
echo "<td>";
echo "<input type='radio' value='{$row["id"]}' name='id2edit'>";
echo "</td></tr>";
}
echo "</table>";
echo "<br>";
echo "<input type='submit' value='Delete selected product' name='button'>";
echo "</form>";
$DBH = null;
} catch (PDOException $e) {
echo '<b>PDOException: </b>', $e->getMessage();
die();
}
I have an inbox code for deleting messages.
If I select one single message it deletes all of them.
How can I fix this ?
Here is my code for delete_message.php :
<?php
$inboxbtn = $_POST['deleteinbox'];
$outboxbtn = $_POST['deleteoutbox'];
if ($inboxbtn)
{
$selectall = $_POST['selectall'];
if ($selectall)
{
$query = mysql_query("SELECT * FROM messages WHERE to_user='$user'");
while ($row = mysql_fetch_assoc($query))
{
mysql_query("UPDATE messages SET to_delete='1' WHERE to_user='$user'");
}
echo "All messages have been deleted.";
}
else
{
$query = mysql_query("SELECT * FROM messages WHERE to_user='$user'");
while ($row = mysql_fetch_assoc($query))
{
$msg_id = $row['id'];
$value = "cb" . "$msg_id";
$checkbox = $_POST[$value];
if ($value)
{
mysql_query("UPDATE `messages` SET `to_delete`='1' WHERE `to_user`='$user' AND `id`='$msg_id'");
}
}
echo "The selected messages have been deleted.";
}
}
elseif ($outboxbtn)
{
$selectall = $_POST['selectall'];
if ($selectall)
{
$query = mysql_query("SELECT * FROM messages WHERE from_user='$user'");
while ($row = mysql_fetch_assoc($query))
{
mysql_query("UPDATE messages SET from_delete='1' WHERE from_user='$user'");
}
echo "All messages have been deleted.";
}
else
{
$query = mysql_query("SELECT * FROM messages WHERE from_user='$user'");
while ($row = mysql_fetch_assoc($query))
{
$msg_id = $row['id'];
$value = "cb" . "$msg_id";
$checkbox = $_POST[$value];
if ($value)
{
mysql_query("UPDATE messages SET from_delete='1' WHERE to_user='$user' AND id='$msg_id'");
}
}
echo "The selected messages have been deleted.";
}
}
else echo "Choose a message to delete.";
?>
And here is the code in inbox.php that has the checkboxes
<?php
$query = mysql_query("SELECT * FROM messages WHERE from_user='$user' AND from_delete='0' ORDER BY id DESC");
$numrows = mysql_num_rows($query);
if ($numrows != 0)
{
echo "<form action='delete_message.php' method='POST'>";
echo "<div class='messages'>
<div class='leftside'><input type='checkbox' name='selectall'><input type='submit' name='deleteoutbox' value='Delete' class'button'></div>
<div class='rightside'>Date</div>
Subject And Message
<div class='clear'></div>
<hr>
</div>";
while ($row = mysql_fetch_assoc($query))
{
$msg_id = $row['id'];
$msg_to_user = $row['to_user'];
$msg_to_id = $row['to_id'];
$msg_from_user = $row['from_user'];
$msg_from_id = $row['from_id'];
$msg_subject = $row['subject'];
$content = nl2br($row['content']);
$msg_date = $row['date'];
$msg_from_delete = $row['from_delete'];
$msg_to_delete = $row['to_delete'];
if (!$msg_from_delete)
{
echo "<div class='messages'>";
echo "<div class='leftside'>
<input type='checkbox' name='cb$msg_id' value='$msg_id'>
<a href='profile.php?id=$msg_to_id' target='_blank'>$msg_to_user</a>
</div>";
echo "<div class='rightside'>$msg_date</div>";
echo "<div id='center' style='margin-left:150px; margin-right:150px;'>
<span class='toggle'><a href='#' onClick='return false'>$msg_subject</a></span>
<div class='hiddenDiv'>
<br /><hr>
<b>$smiles </b>
<br /><br />
</div>
</div>";
echo "<div class='clear'>";
echo "<br /><br /><hr>";
echo "</div></div>";
}
}
echo "</form>";
}
else echo "You Have No Messages In Your Outbox"
?>
Then for the inbox messages it is the same as the outbox but in the inbox form.
How can I fix this ?
The below code is for outbox.php since that's what you have pasted.
First, change your checkbox from:
<input type='checkbox' name='cb$msg_id' value='$msg_id'>
To something like:
<input type='checkbox' name='outbox_ids[]' value='$msg_id'>
And the elseif for the outbox will be:
elseif ($outboxbtn)
{
$selectall = $_POST['selectall'];
if ($selectall)
{
$query = mysql_query("SELECT * FROM messages WHERE from_user='$user'");
while ($row = mysql_fetch_assoc($query))
{
mysql_query("UPDATE messages SET from_delete='1' WHERE from_user='$user'");
}
echo "All messages have been deleted.";
}
else
{
if(isset($_POST['outbox_ids']){
$outbox_msg_ids = array_map('mysql_real_escape_string', $_POST['outbox_ids']);
//all the checked msg id are now stored in $outbox_msg_ids,
//we will loop through the values and pass it to the update query
foreach($outbox_msg_ids as $msg_id){
mysql_query("UPDATE messages SET from_delete='1' WHERE to_user='$user' AND id='$msg_id'");
}
echo "The selected messages have been deleted.";
} //isset if block ends
}
}
Note:
Please, don't use mysql_* functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO, or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.
I am working on PHP and databases for an assignment and I would like some help on my coding. The form is submitted to process.php for processing (code for both are reproduced below). I am getting an undefined index warning for $_POST['CustomerID'] and $_POST['BodyStyle'] when process.php runs (the exact location is noted in the code), and the information entered for these fields on the form won't get inserted or updated in the database. The other fields work as intended, generating no errors and are stored in the database. What is going wrong? How can I fix it?
Process.php:
<?php
$dbname = "cars";
$dbuser = "carsuser";
$dbpass = "carspass250";
$dbconnect = odbc_connect($dbname,$dbuser, $dbpass)
or die ("Could not connect. <br>");
$opcode = (int) $_POST["opcode"];
$recno = (int) $_POST["recno"];
if ( ($opcode < -1) || ($opcode > 1) )
{
echo "Invalid data passed from form! <br>";
exit();
}
if (($opcode == 0) || ($opcode == 1))
{
$CustomerID = $_POST['CustomerID']; //Undefined Index
$year = $_POST['year'];
$make = $_POST['make'];
$model = $_POST['model'];
$BodyStyle = $_POST['BodyStyle']; //Undefined Index
$color = $_POST['color'];
if (!all_fields_ok($CustomerID, $year, $make, $model, $BodyStyle, $color))
{
exit();
}
}
if ($opcode == -1)
$SqlStatement = "DELETE from Vehicle WHERE VehicleID = $recno";
if ($opcode == 0)
{
$SqlStatement = "UPDATE Vehicle SET ".
"CustomerID = '$CustomerID', ".
"Year = '$year', ".
"Make = '$make', ".
"Model = '$model', ".
"BodyStyle = '$BodyStyle', ".
"Color = '$color' ".
"WHERE VehicleID = $recno";
}
if ($opcode == 1)
{
$SqlStatement = "INSERT INTO Vehicle ".
"(CustomerID, Year, Make, Model, BodyStyle, Color) ".
"VALUES ('$CustomerID', '$year', '$make', '$model', '$BodyStyle', '$color')";
}
print $SqlStatement."<br>";
$recs = odbc_exec($dbconnect, $SqlStatement)
or die ("Could not locate database");
print "Database Updated! <br>";
print "<a href=listall.php>Return to List</a> ";
function all_fields_ok($CustomerID, $year, $make, $model, $BodyStyle, $color )
{
$errormsg = "";
$flag = 0;
if ( (!is_numeric($CustomerID)) )
{
$errormsg = $errormsg."Input: $CustomerID <br>";
$errormsg = $errormsg."Only numbers are aloud <br><br>";
$flag=1;
}
if(!(is_numeric($year)) || (!(strlen($year)==4)))
{
$errormsg = $errormsg."Input: $year <br>";
$errormsg = $errormsg."Please enter a four-digit year <br><br>";
$flag=1;
}
if ((!ctype_alpha($make)) )
{
$errormsg = $errormsg."Input: $make <br>";
$errormsg = $errormsg."Please enter the make of the vehicle, characters only<br> <br>";
$flag=1;
}
if (!(ctype_alnum($model)) )
{
$errormsg = $errormsg."Input: $model<br>";
$errormsg = $errormsg."Please enter the model of the vehicle, numbers and characters aloud <br><br>";
$flag=1;
}
if ((!ctype_alpha($BodyStyle)) )
{
$errormsg = $errormsg."Input: $BodyStyle <br>";
$errormsg = $errormsg."Please enter the bodystyle of the vehicle, characters only <br><br>";
$flag=1;
}
if ((!ctype_alpha($color)) )
{
$errormsg = $errormsg."Input: $color <br>";
$errormsg = $errormsg."Please enter the color of the vehicle, characters only. <br><br>";
$flag=1;
}
if ($flag == 1)
{
echo "Data not trustworthy. Please revise input and try again. <br><br>";
echo $errormsg;
return false;
}
else
return true;
}
?>
form:
<?php
$dbname = "cars";
$dbuser = "carsuser";
$dbpass="carspass250";
$dbconnect = odbc_connect($dbname,$dbuser, $dbpass)
or die ("Could not connect. <br>");
$opcode = (int) $_POST["opcode"];
$recno = (int) $_POST["recno"];
if ( ($opcode < -1) || ($opcode > 1) )
{
echo "Invalid data passed from form! <br>";
exit();
}
if ($opcode == 0)
{
$SqlStatement = "SELECT * from Vehicle WHERE VehicleID = $recno";
$recs = odbc_exec($dbconnect, $SqlStatement)
or die ("Could not execute query");
$row = odbc_fetch_array($recs) ;
$VehicleID = $row['VehicleID'];
$CustomerID = $row['CustomerID'];
$year = $row['Year'];
$make = $row['Make'];
$model = $row['Model'];
$BodyStyle = $row['BodyStyle'];
$color = $row['Color'];
}
else
{
$recno = 0;
$VehicleID = 0;
$CustomerID = "";
$year = "";
$make = "";
$model = "";
$BodyStyle = "";
$color = "";
}
print "<h1>Vehicle Record </h1>";
print "<form action=process.php method=post> \n";
print "<table>";
if ($opcode == 0)
print "<tr><td> Record Number:</td><td align=left>$recno</td> </tr>\n";
else
print "<tr><td> Record Number: </td><td align=left>New Record</td> </tr>\n";
print "<tr><td> Customer ID: </td>";
print "<td> <input type=text name=CustomerID value=\"$CustomerID\"></td></tr> \n";
print "<tr><td> Year: </td>";
print "<td> <input type=text name=year value=\"$year\"></td></tr> \n";
print "<tr><td> Make: </td>";
print "<td> <input type=text name=make value=\"$make\"></td></tr> \n";
print "<tr><td> Model: </td>";
print "<td> <input type=text name=model value=\"$model\"></td></tr> \n";
print "<tr><td> Style: </td>";
print "<td> <input type=text name=BodyStyle value=\"$BodyStyle\"></td></tr> \n";
print "<tr><td> Color: </td>";
print "<td> <input type=text name=color value=\"$color\"></td></tr> \n";
print "<input type=hidden name=opcode value=$opcode> \n";
print "<input type=hidden name=recno value=$recno> \n";
print "<tr><td> <input type=submit value='Submit Record'></td><td></td></tr> \n \n";
print "</table>";
print "</form>";
odbc_close($dbconnect);
?>
The variables in your $_POST data are defined by the input name attributes, so if you say this
<input name="customer" ... />
<input name="style" ... />
you need to look for
$_POST['customer']
$_POST['style']
so either change your POST lookups or your input names, and make them match.
Also, you should check your html standards, the attributes values should go between "" and you should close all tags with either or finishing it with />
you're not getting the CustomerID and the BodyStyle variables from your POST data, there's something wrong with the request (your form, or whatever you're using)
Correct this column...it cannot have space in it.
"Body Style = '$BodyStyle', ".