|
Posted by Jim Moseby on 11/14/81 11:22
>
> Somehow my intent has been turned around here and I apologise.
>
> I do not want to use *any* client side validation. I only want to do
> server side validation and server side storage.
>
> My intent was to remove the client from as much as possible
> of this - if
> I didn't need their information I wouldn't even allow clients!! :)
>
> What I wanted to do was this:
>
>
> p. 1 : I send client page one, they send answers. SUBMIT
> sends to page 2
> script.
>
> p 2. Before displaying anything to the client, Page 2 script
> validates
> input from page 1. If there are problems, page 2 script
> redisplays page
> one questions with highlights around problems. Clicking submit then
> resubmits page one data to page 2 script.
>
> Once page 2 script validates all page 1 answers, page 2 script stores
> all those answers to a SESSION, then sends PAGE 2 QUESTIONS ONLY (no
> $_POST information) to client. Client answers page 2 questions and
> clicking submit submits PAGE 2 QUESTIONS to page 3 script.
>
> p 3. Before displaying anything to the client, Page 3 script
> validates
> input from page 2 questions. If there are problems, page 3 script
> redisplays page 2 questions with highlights around problems. Clicking
> submit resubmits page 2 data to page 3 script.
>
> Once page 3 script validates all page 2 answers, the script
> stores all
> those answers to a SESSION, then sends PAGE 3 QUESTIONS ONLY
> (no $_POST
> information) to client. Client answers page 3 questions and clicking
> submit submits PAGE 3 QUESTIONS to page 4 script.
>
> At this point, if the client goes off for a bite, or two weeks
> backpacking in the Anapurna region, I'm fine, because the
> information is
> stored in the session (I have a very small group taking this
> questionnaire, all have a vested interested in filling it in, so I am
> not too worried abou their going aaway from it for more than a couple
> days max).
>
> Once they complete the last set of questions, I say thanks
> much, get all
> the information out of their SESSION, insert it into the db, send
> confirmation emails all around and we're done.
>
> Is this possible? How?
>
> Thanks!
This is exactly the scenario I suggested. The only place I believe your
logic fails is that the session will time out after a period of time and all
data will be lost. If you suspect that a user may need to resume an
interrupted session, you need to store the data somewhere (DB, cookies, etc)
Consider this over-simplified and (probably syntactically incorrect)
example:
<? // Page 1
session_start();
?>
<html>
<head>
<title>Page 1</title>
</head>
<body>
<form method="POST" action="page2.php">
<p>NAME: <input type="text" name="NAME" value="<? echo
$_SESSION['Name']?>"></p>
<p><input type="submit" value="Submit" name="B1"></p>
</form>
</body>
</html>
--------------------------------------------------------
<? // Page 2
$_SESSION['Name'] = $_POST['NAME']; // commit to session variables
// Validate data here
if (data problems){die('<meta http-equiv="refresh"
content="0;url=page1.php">');}
?>
<html>
<head>
<title>Page 1</title>
</head>
<body>
<form method="POST" action="page3.php">
<p>ADDRESS: <input type="text" name="ADDRESS" value="<? echo
$_SESSION['Address']?>"></p>
<p><input type="submit" value="Submit" name="B1"></p>
</form>
</body>
</html>
--------------------------------------------------------
<? // Page 3
$_SESSION['Address'] = $_POST['ADDRESS'];// commit to session variables
// Validate data here
if (data problems){die('<meta http-equiv="refresh"
content="0;url=page1.php">');}
?>
<html>
<head>
<title>Page 1</title>
</head>
<body>
<form method="POST" action="page4.php">
<p>PHONE: <input type="text" name="PHONE" value="<? echo
$_SESSION['Phone']?>"></p>
<p><input type="submit" value="Submit" name="B1"></p>
</form>
</body>
</html>
This is incredibly over-simplified, but you get the idea. If you want to
redisplay the form and highlight data errors, you may want to POST to
PHP_SELF, validate there, redisplay the form if necessary, and meta-refresh
to the next page if all is OK.
JM
Navigation:
[Reply to this message]
|