tqla Posted September 16, 2008 Share Posted September 16, 2008 Hello. Is it possible to have a php form submit to the form processor script automatically without needing to hit the submit button? Wait, this is not as weird as it sounds! A form gets filled out and then the user clicks submit. The form then gets sent to another script (below) that does a little bit to the POST data (Sessions, Implode, etc) and then puts the POST data into hidden fields to be sent it off to the form processor (register.php). The problem is that the user will need to hit Submit again. I don't want that. I want it to sent the new POST data automatically. <?php session_start(); ?> <html> <head> <title>Untitled Document</title> </head> <body> <?php $_SESSION['FirstName'] = $_POST['FirstName']; $_SESSION['LastName'] = $_POST['LastName']; $_SESSION['Email'] = $_POST['Email']; $_SESSION['Custom1'] = $_POST['Custom1']; $_SESSION['Custom2'] = $_POST['Custom2']; $_SESSION['Address'] = $_POST['Address']; $_SESSION['City'] = $_POST['City']; $_SESSION['State'] = $_POST['State']; $_SESSION['Zip'] = $_POST['Zip']; $_SESSION['Country'] = $_POST['Country']; $_SESSION['Phone'] = $_POST['Phone']; $_SESSION['Custom3'] = $_POST['Custom3']; $_SESSION['Custom4'] = $_POST['Custom4']; $_SESSION['Custom5'] = $_POST['Custom5']; $_SESSION['ClientNum'] = $_POST['ClientNum']; $_SESSION['Join_List'] = $_POST['Join_List']; $info = implode(', ',$Custom5); ?> <form name="form1" method="post" action="register.php " > <input name="FirstName" type="hidden" value="<?php echo $FirstName ?>" /> <input name="LastName" type="hidden" value="<?php echo $lastName ?>" /> <input name="Email" type="hidden" value="<?php echo $Email ?>" /> <input name="Custom1" type="hidden" value="<?php echo $Custom1 ?>" /> <input name="Custom2" type="hidden" value="<?php echo $Custom2 ?>" /> <input name="Address" type="hidden" value="<?php echo $Address ?>" /> <input name="City" type="hidden" value="<?php echo $City ?>" /> <input name="State" type="hidden" value="<?php echo $State ?>" /> <input name="Zip" type="hidden" value="<?php echo $Zip ?>" /> <input name="Country" type="hidden" value="<?php echo $Country ?>" /> <input name="Phone" type="hidden" value="<?php echo $Phone ?>" /> <input name="Custom3" type="hidden" value="<?php echo $Custom3 ?>" /> <input name="Custom4" type="hidden" value="<?php echo $Custom4 ?>" /> <input name="Custom5" type="hidden" value="<?php echo $value ?>" /> <input name="ClientNum" type="hidden" value="<?php echo $ClientNum ?>" /> <input name="Join_List" type="hidden" value="<?php echo $Join_List ?>" /> <input type="submit" name="Join List" value="Join List"> </form> </body> Link to comment https://forums.phpfreaks.com/topic/124403-solved-submit-form-automatically/ Share on other sites More sharing options...
Garethp Posted September 16, 2008 Share Posted September 16, 2008 echo "<script type=\"text/javascript\"> document.formname.submit() </script>"; Link to comment https://forums.phpfreaks.com/topic/124403-solved-submit-form-automatically/#findComment-642444 Share on other sites More sharing options...
DarkWater Posted September 16, 2008 Share Posted September 16, 2008 If it's already in the session, why not just use a header() redirect and use the session variables? Or just do what you'd do on this page but on register.php so you only need one page... >_> Link to comment https://forums.phpfreaks.com/topic/124403-solved-submit-form-automatically/#findComment-642446 Share on other sites More sharing options...
tqla Posted September 16, 2008 Author Share Posted September 16, 2008 Garethp I ended up using a javascript method similar to the one you posted. DarkWater, I have no access to the resister.php page so I cannot modify it. I can only send it $_POST's, also the implode function the only thing that made this form necessary in the first place. Thanks! Link to comment https://forums.phpfreaks.com/topic/124403-solved-submit-form-automatically/#findComment-642486 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.