- Jul 5, 2001
- 5,726
- 35
- 91
I have an issue (the first of many but I think this one issue is causing the rest of them) with my session_start.
I have succesfully passed a variable from on page to another which is a primary key for a table. I have succesfully used that variable to pull data from a database to populate a html form so that I can edit the data. But when I submit the edited data and get a bunch of errors the first of which is this...
I do not understand why am getting this error seeing as I have already used this variable in a query to the database with no errors at all.
Here is my code...
Thanks in advance.
I have succesfully passed a variable from on page to another which is a primary key for a table. I have succesfully used that variable to pull data from a database to populate a html form so that I can edit the data. But when I submit the edited data and get a bunch of errors the first of which is this...
Notice: Undefined index: serialNumber in C:\wamp\www\edit.php on line 10
I do not understand why am getting this error seeing as I have already used this variable in a query to the database with no errors at all.
Here is my code...
Code:
<html>
<head>
<title>Development Get Page</title>
</head>
<body>
<?php
echo '<h1>Gizmo Bids Database (Beta!)</h1>';
session_start();
$serialNumberValue = $_GET['serialNumber'];
echo "The Serial Number is: " .$serialNumberValue. ". <br />"; //this code is just to check to see if my variable passing is working
$con = mysqli_connect("localhost","root","","gizmo");
$form_query = "select * from bids where serialNumber = $serialNumberValue";
$list_sql = "select serialNumber from bids";
$form_result = mysqli_query($con,$form_query);
$form_row = mysqli_fetch_assoc($form_result);
// Check connection
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
else
{
echo "you are connected! <br> <br>";
}
if(isset($_POST['dueDate']) &&
isset($_POST['dueTime']) &&
isset($_POST['state']) &&
isset($_POST['organization']) &&
isset($_POST['description']) &&
isset($_POST['solicitation']) &&
isset($_POST['note']) &&
isset($_POST['website']))
{
$dueDate = $_POST[dueDate];
$dueTime = $_POST[dueTime];
$stateCode = $_POST[state];
$organization = $_POST[organization];
$description = $_POST[description];
$solicitation = $_POST[solicitation];
$note = $_POST[note];
$website = $_POST[website];
$query = "UPDATE bids
SET dueDate = $dueDate,
dueTime = $dueTime,
stateCode = $stateCode,
organization = $organization,
description = $description,
solicitation = $solicitation,
note = $note,
website = $website
WHERE serialNumber = $serialNumberValue";
if (!mysqli_query($query,$con))
echo "Edit has failed: $query <br />" . mysqli_error() . "<br /><br />";
}
echo "you have made an edit!";
//This is the form for the page. The fields are automatically populated with the current data
echo <<<_END
<form action="edit.php" method="post">
<pre>
Due Date: <input type="date" name="dueDate" id="dueDate" value=$form_row[dueDate] /> Format YEAR-MO-DA <br><br>
Due Time: <input type="text" name="dueTime" value=$form_row[dueTime] /> Format HR:MIN:SEC (Military Time)<br><br>
State: <input type="text" name="state" value=$form_row[stateCode] /> Format XX <br><br>
Organization: <input type="text" name="organization" value=$form_row[organization] /> <br><br>
Description: <input type="text" name="description" value=$form_row[description] /> <br><br>
Solicitation: <input type="text" name="solicitation" value=$form_row[solicitation] /> <br><br>
Note: <input type="text" name="note" value=$form_row[note] /> Remove the slash if you don't want it!!! <br><br>
Website: <input type="text" name="website" value=$form_row[website] /> <br><br>
<input type="submit" value="Edit Record" />
</pre>
</form>
_END;
?>
</body>
</html>
Thanks in advance.