Question : Trying to understand sessions.

I have a php form. around 10 fields.
when someone fills it out and submits, it is entered into my MySQL DB. At which point they are taken to a page to confirm the info.
From the "confirm page they have the option to edit or confirm. If they confirm it runs a script to send me an email that they have entered the form.
Currently I'm using "SELECT * FROM myTable ORDER BY id DESC" to get the info from the first page to the "confirm page" and "edit page". I realize this is a very bad idea, and would like to change it.

What I've been trying to do (with no luck)is use session or cookies to return the info from the DB.

My latest attempt using DW...

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
 $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

 $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

 switch ($theType) {
   case "text":
     $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
     break;    
   case "long":
   case "int":
     $theValue = ($theValue != "") ? intval($theValue) : "NULL";
     break;
   case "double":
     $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
     break;
   case "date":
     $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
     break;
   case "defined":
     $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
     break;
 }
 return $theValue;
}
}

$colname_rs_request = "-1";
if (isset($_SESSION['RequestName'])) {
 $colname_rs_request = $_SESSION['RequestName'];
}
mysql_select_db($database_My_DB, $My_DB);
$query_rs_request = sprintf("SELECT * FROM Request WHERE RequestName = %s", GetSQLValueString($colname_rs_request, "text"));
$rs_request = mysql_query($query_rs_request, $My_DB) or die(mysql_error());
$row_rs_request = mysql_fetch_assoc($rs_request);
$totalRows_rs_request = mysql_num_rows($rs_request);
?>


Answer : Trying to understand sessions.

>>  setcookie('SubForm',$_POST['RequestName'], time()+(60*8));

Okay, now you have a cookie named SubForm.  So filter the recordset against Cookie Variable SubForm
Random Solutions  
 
programming4us programming4us