Jump to content


Photo

posting without clicking submit


  • Please log in to reply
5 replies to this topic

#1 deanogallagher

deanogallagher
  • Members
  • Pip
  • Newbie
  • 1 posts

Posted 13 July 2006 - 10:52 AM

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

#2 GingerRobot

GingerRobot
  • Staff Alumni
  • Advanced Member
  • 4,086 posts
  • LocationUK

Posted 13 July 2006 - 11:01 AM

Show us what you have so far

#3 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 13 July 2006 - 12:02 PM

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.

Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.


#4 GingerRobot

GingerRobot
  • Staff Alumni
  • Advanced Member
  • 4,086 posts
  • LocationUK

Posted 13 July 2006 - 12:03 PM

From what i can workout, the title is misleading - thats why im asking for his form and php code so far.

#5 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 13 July 2006 - 12:24 PM

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

#6 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 13 July 2006 - 03:18 PM

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 <?php echo $_SERVER['PHP_SELF']; ?>

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


Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users