Jump to content

[SOLVED] Force a form to submit


limitphp

Recommended Posts

On my registration page, when they hit the button to register it takes them to another mode on the register page that checks all the info.

 

In other words.....register.php has a form :

<FORM NAME="frmRegister" METHOD="post" ACTION="register.php">

<INPUT TYPE="hidden" NAME="mode" VALUE="1">

 

When they click the register button mode = 1

if mode = 1 check all info to make sure its valid.

 

If it is valid, send them to verify.php and send some variables via a form.

 

Is that possible?

Right now I have another form on register.php

<FORM NAME="frmSuccess" METHOD="post" ACTION="verify.php">
<INPUT TYPE="hidden" NAME="mode" VALUE="1">
<INPUT TYPE="hidden" NAME="email" VALUE="<?php echo $email?>">	
<INPUT TYPE="hidden" NAME="username" VALUE="<?php echo $username?>">
</FORM>
[code]

When all their info checks out I try to force a submit on the above form so they will go to verify.php with all those variables
I use this javascript: document.frmSuccess.submit()

But right now it doesn't seem to work.
Am I doing something wrong?
Is my logic messed up?

Link to comment
https://forums.phpfreaks.com/topic/136726-solved-force-a-form-to-submit/
Share on other sites

Put this in verify.php:

<?php if (isset($_POST['submit'])) {
$user = $_POST['username'];
$email = $_POST['email'];}

change register.php to this:

<FORM NAME="frmSuccess" METHOD="post" ACTION="verify.php">
<INPUT TYPE="hidden" NAME="email" VALUE="<?php echo $email?>">	
<INPUT TYPE="hidden" NAME="username" VALUE="<?php echo $username?>">
        <input type="submit" name="submit" />
</FORM>

Put this in verify.php:

<?php if (isset($_POST['submit'])) {
$user = $_POST['username'];
$email = $_POST['email'];}

change register.php to this:

<FORM NAME="frmSuccess" METHOD="post" ACTION="verify.php">
<INPUT TYPE="hidden" NAME="email" VALUE="<?php echo $email?>">	
<INPUT TYPE="hidden" NAME="username" VALUE="<?php echo $username?>">
        <input type="submit" name="submit" />
</FORM>

 

I tried adding the <input type="submit" name="submit" /> and it still didn't work.

 

I'm thinking its not submiting the form because the as the page loads, it gets to the javascript where it says document.frmSuccess.submit()

but the page hasn't finished loading and the form frmSuccess doesn't exist yet.

 

Is there anyway to fix this problem?

How can I dely the javascript: document.frmSuccess.submit() until after the page loads?

 

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.