Jump to content

posting without clicking submit


deanogallagher

Recommended Posts

Hi,

I'm validating a form by posting the form to itself, which means if the form is valid it just comes back from the server the same, is there a way i can post if valid.  Basically I want to be able to do the following after submitting the form to itself and processing the validation:

if (valid)
  show next.php
else
  print error messages

Thanks in advance

Dean
Link to comment
https://forums.phpfreaks.com/topic/14467-posting-without-clicking-submit/
Share on other sites

I'm not sure if this will work, but could you do it with a mix of JavaScript and PHP?
[code]if(valid) {
    echo "<script type='text/javascript'>document.myformname.submit();</script>";
} else {
    //print error messages
}[/code]
Alternatively, you could store the information you want to pass within a session variable, or even pass it through the URL...
Hmm.. I think now I got what he trying to ask, hope I got it right now.

You create your form scripts, then name the submit "submit".
And your form post method is [b]<?php echo $_SERVER['PHP_SELF']; ?>[/b]

So you just need to do this,
[code]if (isset($_POST['submit'])) {
  // show next page
} else {
  // echo error
}[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.