OK - I am back to have another crack at this, ty for the posts.
I have implmented a print_r within the script and it is echoing the value ‘1’ constantly.
I am beginning to think i have something fundamentally wrong somewhere else, as i have set a variable at different places within the controller to see what is running (by the value it is returning). and nothing is coming back as i expected.
I have taken the liberty of pasting my complete code (well i have stripped out lots of none essentials)
<?php
include $_SERVER['DOCUMENT_ROOT']. '/landp/site/includes/db.inc.php';
include $_SERVER['DOCUMENT_ROOT']. '/landp/site/includes/magicquotes.inc.php';
$test='start';
/*//check logged in
require_once $_SERVER['DOCUMENT_ROOT']. '/landp/site/includes/access.inc.php';
if (!userisloggedin())
{
include '../login.html.php';
exit();
}*/
// add property comparable details - call form
if (isset($_GET['addproperty']))
{
include 'form.html.php';
exit();
}
//add property details - add to DB
if (isset ($_POST['action']) and $_POST['action'] == 'Add')
{
//get and declare variables from form
// declare SQl variable
if (!mysqli_query ($link, $sql))
{
$error = 'Error adding property details: ' .mysqli_error($link). " ";
include 'error.html.php';
exit();
}
header ('Location: .');
exit();
}
//delete property details
if (isset($_POST["action"]) and $_POST['action'] == 'Delete')
{
$id = mysqli_real_escape_string($link, $_POST['property_id']);
$sql = "delete from property where id = '$id'";
if (!mysqli_query($link, $sql))
{
$error = 'Error deleting property: ' . mysqli_error($link);
include 'error.html.php';
exit();
}
header('Location: .');
exit();
}
//Edit Property information
if (isset($_POST['action']) and $_POST['action'] == 'Edit')
{
$id = mysqli_real_escape_string($link, $_POST['property_id']);
$result = mysqli_query($link, 'select * from property where id ="' .$id. '" ');
$test = 'standard';
if (!$result)
{
$error = 'Error fetching property list: ' . mysqli_error($link);
include 'error.html.php';
exit();
}
while ($row = mysqli_fetch_array($result))
{
$updates[] = array(
'House_name' => $row['House_name'],
'house_number' => $row['house_number'],
'addline1' => $row['addline1'],
'addline2' => $row['addline2'],
'town' => $row['town'],
'county' => $row['county'],
'postcode' => $row['postcode'],
'bed' => $row['bed'],
'living' => $row['living'],
'kitchen' => $row['kitchen'],
'bath' => $row['bath'],
'parking' => $row['parking'],
'heating' => $row['heating'],
'size' => $row['size'],
'price' => $row['price'],
'sold_status' => $row['sold_status'],
'sold_date' => $row['sold_date'],
'cond' => $row['cond'],
'prop_note' => $row['prop_note']);
}
include './updateform.html.php';
$test=='something';
if (isset($_POST['action']) and $_POST['action'] == 'Quit')
{
$test = 'quit';
include $_SERVER['DOCUMENT_ROOT']. '/landp/site/Property_comp/form.html.php';
exit();
}
if (isset($_POST['action']) and $_POST['action'] == 'Update')
{
$test = 'yeah baby';
//check to see if new information input
// write old and new info into table property
$sql =
if (!mysqli_query ($link, $sql))
{
$error = 'Error adding property details: ' .mysqli_error($link). " ";
include 'error.html.php';
exit();
}
header ('Location: .');
exit();
}
$test = 'straight through';
exit();
}
//get data from property table to list
$result = mysqli_query($link, 'SELECT * FROM property');
if (!$result)
{
$error = 'Error fetching property list: ' . mysqli_error($link);
include 'error.html.php';
exit();
}
while ($row = mysqli_fetch_array($result))
{
$props[] = // set array
}
include 'list.html.php';
?>
The strange part is that I have the buttons working as intended within others parts of the code (above shows a ‘edit’ and ‘delete’ buttons which do work!!).
Hence i am beginngin to think its isnt the If POST values that are incorrect?!?
many thanks
Dibley