Merlin Morgenstern wrote on 2009-11-24 18:38:

This is not so easy. I am doing some checking with php on the values and if one failes php returns via GET to the form with the help of header location:

       $parameter =  "&demo=this";
       HEADER("Location:/test.html?error=1".$parameter);
       exit;

I would need to change way to many things in order to simply change to post.

Isn't there another way?

This is what I normally do with larger forms:

1. create the form as a function: form()
2. submit the form to the same page
3. test relevant input and if the fail print form()

Example:

function form() {
print '
<form action="'.$_SERVER['PHP_SELF'].'" method="post">
<input type="text" name="email" value="'.$_POST['email'].'">
<input type="submit" name="submit" value="send form">
</form>';
}

if($_POST['submit']) {
  // test email is entered
  if(!$_POST['email']) {
    print "error: you must enter an e-mail address";
    form();
  }
  else {
    // do stuff from here...
  }
}
else
  form();

With a 50 field form this is a nice approach for me :-)

--
Kind regards
Kim Emax - masterminds.dk

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to