DaveRandom, thanks again..
I have done some of the confirmation page but something was not right; Below is my attempt.
BTW, I found one error back at the post#5 - When I tried to click 'Create User' hyper-link on my main page (index page) it will take me to blank form page which is correct, but then when look at the source code (HTML), there is an error saying:
Notice: Undefined index: id on line 138
Line 138 shown here:
<input type="hidden" name="id" value="<?php echo $_GET['id']; ?>">
As far as I understand we can delete these now, cant we?:
<input type="hidden" name="id" value="<?php echo $_GET['id']; ?>">
<input type="hidden" name="mode" value="<?php echo $mode; ?>">
as we already use the foreach function, am I make sense? as far as I know if we use foreach statement then no there no need the 'hidden' inputs anymore? Please correct me if am wrong.
This is my attempt, of the confirmation page so far but it still not working properly as when I clicked the 'Create User' hyper-link and filled the form and submitted them the button change to 'Modify' (confirmation page) instead of 'Create' - and when I pressed the button (Modify or Create on the confirmation page still) it won't let me to go to main page (index page)
session_start();
<?php
require 'includes/application.php';
$id = (int)$_SESSION['id'];
$mode = $_SESSION['mode'];
if (!isset ($_SESSION['name']) && isset($id)) {
$mode = "Modify";
$modify_sql = "UPDATE persons SET name = '".$_SESSION['name']."', surname = '".$_SESSION['surname']."', address = '".$_SESSION
['address']."', mobile = '".$_SESSION['mobile']."', `dept_id`= '".$_SESSION['dept']."' WHERE persons.id = " . $id;
echo $modify_sql;
$confirm_modify = mysql_query ($modify_sql) or die (mysql_error());
header("Location: indexPage.php?id=".$id."&page=modify");
} else if (!isset($_SESSION['name']) && !isset($id)) {
$mode = "Creating";
$create_sql = "INSERT INTO persons SET `Name`='$name', `Surname`='$surname', `dept_id`='$dept', `Address`='$add',
`Mobile`='$mobile' ";
$confirm_create = mysql_query ($create_sql) or die (mysql_error());
header("Location: indexPage.php?id=".mysql_insert_id()."&page=create");
}
?>
...
...
<td colspan="2" align="center"><p>
<input type="button" value="Back" onclick="history.go(-1)" />
<?php
foreach ($_POST as $key => $val)
$_SESSION[$key] = $val;
?>
<!--input type="hidden" name="mode" value="<?php echo $mode;?>" /-->
<input type="submit" value="<?php echo ($mode == "Creating") ? 'Create' : 'Modify';?>"/>
</td>
...
...