close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues


validation question

Thread began 3/10/2010 2:08 pm by runner1899402928 | Last modified 3/11/2010 1:36 pm by Jason Byrnes | 673 views | 1 replies |


validation question

I have been working on a multi page form for my site. I got the functionality all working but now I was wondering how to validate that no fields are left blank during the process. Any help would be appreciated. I am using sessions to store my data

// Turn on sessions

// Figure out what stage to use
if (($_SERVER["REQUEST_METHOD"] == "GET") || (! isset($_POST["stage"]))) {
$stage = 1;
} else {
$stage = (int) $_POST["stage"];

// Save any submitted data
if ($stage > 1) {
foreach ($_POST as $key => $value) {
$_SESSION[$key] = $value;

if ($stage == 1) { ?>

<form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post">

Name: <input type="text" name="name"/> <br/>
Age: <input type="text" name="age"/> <br/>

<input type="hidden" name="stage" value="<?php echo $stage + 1 ?>"/>
<input type="submit" value="Next"/>

<?php } else if ($stage == 2) { ?>

<form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post">

Favorite Color: <input type="text" name="color"/> <br/>
Favorite Food: <input type="text" name="food"/> <br/>

<input type="hidden" name="stage" value="<?php echo $stage + 1 ?>"/>
<input type="submit" value="Done"/>

<?php } else if ($stage == 3) { ?>

Hello <?php echo $_SESSION["name"] ?>.
You are <?php echo $_SESSION["age"] ?> years old.
Your favorite color is <?php echo $_SESSION["color"] ?>
and your favorite food is <?php echo $_SESSION["food"] ?>.

<?php } ?>

Sign in to reply to this post

Jason ByrnesWebAssist

use the server validations included in CSS Form Builder to validate that all fields are filed in.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...