Hi maybe someone can point me in the right direction here....
I have 4 php pages.
The first one insert information via sql statement
the 2,3,4 update the same row.
the mysql_insert_id() are a hidden field on the first page...
Then the $id are sent with the headers in order to identify the same row as the first page and then to update it.
But is doesn't work the error message is Undefined variable: prop_ID so the variable are not being recorgnized.
Here the scripts....
lisiting1.php
<?php
session_start();
include ("../includes/conn.inc.php");
if ((isset($SESSION['user_logged'])) == "" || (isset($SESSION['user_password'])) == "")
{
include_once ("../includes/unlogged_user.php");
}
else { //1
function clean_inputs() {
foreach ($POST as $key => $value) {
$POST[$key] = htmentities(trim($value), ENT_QUOTES);
}
}
if(isset($POST["Submit"])) {
//2
$result = mysql_query("SELECT username FROM right_customer
WHERE username = '" . $SESSION['user_logged']. "'");
if (!$result) { echo "there was a problem";
exit;
}
$row = mysql_fetch_row($result);
$username = $row[0]; // username
$prop_ID = $POST["prop_ID"];
$sale = $POST["sale"];
$number = $POST["number"];
$street = $POST["street"];
$suburb = $POST["suburb"];
$city = $POST["city"];
$province = $POST["province"];
$post = $POST["post"];
$distance = $_POST["distance"];
$date = time();
$query = "INSERT INTO right_prop(prop_ID, username, date_auto, sale, number, street,
suburb, city, province, post, distance, type, price, house_size, prop_size, bedrooms,
bedroom1, bedroom2, bedroom3, bathrooms, bathroom_size, rooms, study, livingroom, diningroom, kitchen, garages, garage_size,
swimmingpool, serveants, toolshed, jetmaster, jacuzzi, sauna, workshop, BBQ,
general)
VALUES (NULL, '$username', '$date', '$sale', '$number', '$street', '$suburb', '$city', '$province', '$post', '$distance',
'', '','','','','','','','','','','','','','','','','','','','','','','','','' )";
if (mysql_query($query)) {
// If successful, forward to next page
[COLOR=Red] header ("Location: listing2.php?SQLprop_ID=$prop_ID");[/COLOR]
exit();
} else { //4
// If not successful, print an error message on this page
$error = "We couldn't insert your information into database, there was an error.
Please try again. if the problem persist please contact the RightMove Web Administrator";
} //4
}
include ("listing_form1.php");
}
?>
linsting_form1.php
<link href="css/whitetehomabody.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style2 {color: #CC0033}
-->
</style>
<link href="../css/whitetehomabody.css" rel="stylesheet" type="text/css">
<form name="proplist_address" method="POST" action="listing1.php">
<table width ="650" border="1" bgcolor="#99CCCC" cellpadding="3" cellspacing="0">
<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF" class="whitetahoma">
<td colspan="2"valign="top" class="menu_names">Step 1 <img src="../Pics/GREENBUTTON.gif" width="13" height="13"> <img src="../Pics/LINE.gif" width="61" height="10"> Step 2 <img src="../Pics/GREENGREYBUTTON.gif" width="13" height="13"> <img src="../Pics/LINE.gif" width="61" height="10"> Step 3 <img src="../Pics/GREENGREYBUTTON.gif" width="13" height="13"> <img src="../Pics/LINE.gif" width="61" height="10"> Step 4 <img src="../Pics/GREENGREYBUTTON.gif" width="13" height="13"> <img src="../Pics/LINE.gif" width="61" height="10"> Finish <img src="../Pics/GREENGREYBUTTON.gif" width="13" height="13"></td>
</tr>
<tr bordercolor="#99CCCC" bgcolor="#3399FF" class="whitetahoma">
<td width="650"valign="top">
Please Enter the following Property Details:<br>
</td>
<td align="right" valign="top" bordercolor="#FFFFFF" bgcolor="#FFFFFF" > [COLOR=Red]<input name="prop_ID" type="hidden" value="mysql_insert_id()">[/COLOR]<?php include_once ("../includes/logged_user.php"); ?>
</td>
</tr>..........................................
listing2.php
<?php
session_start();
include ("../includes/conn.inc.php");
if ((isset($SESSION['user_logged'])) == "" || (isset($SESSION['user_password'])) == "")
{
include_once ("../includes/unlogged_user.php");
}
else { //1
function clean_inputs() {
foreach ($POST as $key => $value) {
$POST[$key] = htmentities(trim($value), ENT_QUOTES);
}
}
if(isset($_POST["Submit"])) { //2
$prop_ID = $POST["prop_ID"];
$type = $POST["type"];
$price = $POST["price"];
$house_size = $POST["house_size"];
$prop_size = $POST["prop_size"];
$bedrooms = $POST["bedrooms"];
$bedroom1 = $POST["bedroom1"];
$bedroom2 = $POST["bedroom2"];
$bedroom3 = $POST["bedroom3"];
$bathrooms = $POST["bathrooms"];
$query = "UPDATE right_prop SET prop_ID = '',
username = '', date_auto = '', sale ='', number = '',street = '',
suburb = '', city = '', province ='', post ='', distance = '',
type = '$type', price = '$price', house_size = $house_size', prop_size = $prop_size',
bedrooms = '$bedrooms', bedroom1 = $bedroom1', bedroom2 = '$bedroom2', bedroom3 = '$bedroom3',
bathrooms = '$bathrooms',
bathroom_size ='', rooms = '', study = '', livingroom = '', diningroom = '', kitchen = '',
garages = '', garage_size = '',
swimmingpool = '', serveants = '', toolshed = '', jetmaster = '',
jacuzzi = '', sauna = '', workshop = '', BBQ = '', general = ''
WHERE prop_ID = $prop_ID ";
if (mysql_query($query)) {
// If successful, forward to next page
header('Location: listing3.php?SQLid=$prop_id');
exit();
} //2
else { //4
// If not successful, print an error message on this page
$error = "We couldn't insert your information into database, there was an error.
Please try again. if the problem persist please contact the RightMove Web Administrator";
} //4
} //1
include ("listing_form2.php");
}
?>
listing_form2.php
with no hidden fields.....