Jump to content

Archived

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

deanogallagher

posting without clicking submit

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

Share this post


Link to post
Share on other sites
Is that possible ?
From my knowledge of php, I don't think it's possible. It's just like how do you tell the script to react when the page is blank ? Hope you understand what I mean.

Share this post


Link to post
Share on other sites
From what i can workout, the title is misleading - thats why im asking for his form and php code so far.

Share this post


Link to post
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...

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

×

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.