Lectrician Posted March 15, 2009 Share Posted March 15, 2009 I am developing some code in PERL as this is what my site runs with. However, I want to use some PHP code to do some image manipulation. I have a form created with perl which is submitted to a PHP script. So far this script is VERY simple! The script takes the form elements and outouts them into a redirect url (for example www.myurl.com/cgi-bin/script.pl?name=tom;age=20) I am doing this as I want the submitted form from the perl script to goto the PHP script, run through the script and then redirect back to the perl script with the data. I would prefer not to place the form element data into the URL in the redirect back to the perl script. So, my question....... Can you use perl to automatically submit a form with hidden elements? I have tried creating a form and using javascript to submit it, but I have trouble getting HTML, PHP and JAVASCRIPT running together! I am VERY new to PHP! Any help appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/149506-php-form-automatically-submit/ Share on other sites More sharing options...
Stephen68 Posted March 15, 2009 Share Posted March 15, 2009 Couldn't you just use javascript onLoad() to submit the form? Not to sure about that thought. Something in the body tag maybe or make a fuctnion.. <body onLoad="document.form.submit();"> hope that helps some Stephen Quote Link to comment https://forums.phpfreaks.com/topic/149506-php-form-automatically-submit/#findComment-785182 Share on other sites More sharing options...
Lectrician Posted March 15, 2009 Author Share Posted March 15, 2009 Thanks, Thats what I was thinking of doing with the javascript. I was trying to use this instead <form name="myform" method="post" action="recieve.php"> <input type="hidden" name="user" value="$user"> <script language="JavaScript">document.myform.submit();</script></form> Thing is, the $user variable can only be used in the PHP tags. It doesn't work in the HTML after the PHP code I have. Do I need to write the form into the PHP tags using "print"? When I try this I get parse errors? Quote Link to comment https://forums.phpfreaks.com/topic/149506-php-form-automatically-submit/#findComment-785193 Share on other sites More sharing options...
Stephen68 Posted March 15, 2009 Share Posted March 15, 2009 no just wrap $user in php tags <form name="myform" method="post" action="recieve.php"> <input type="hidden" name="user" value="<?php echo $user ?>"> <script language="JavaScript">document.myform.submit();</script></form> Quote Link to comment https://forums.phpfreaks.com/topic/149506-php-form-automatically-submit/#findComment-785297 Share on other sites More sharing options...
Lectrician Posted March 17, 2009 Author Share Posted March 17, 2009 Thanks - I figured it in the end! Thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/149506-php-form-automatically-submit/#findComment-786948 Share on other sites More sharing options...
Lectrician Posted March 17, 2009 Author Share Posted March 17, 2009 One more thing..... How can I prevent the PHP scripft from re-running after a page refresh? My users fill ina form, the data is submitted to the PHP script, the PHP script plays with the data and then sends it back off to a Perl script (where it actually originated from). The auto submit of the form is doing this. once my Perl script has finished with the data from the PHP submitted, if a user presses the back button they get the blank PHP page. If they then refresh this page the data from the initial form is acted on twice (in my case, the same images are uploaded again, and given a different random filename). I would like to prevent this! New to PHP, so please be patient with me :-) Quote Link to comment https://forums.phpfreaks.com/topic/149506-php-form-automatically-submit/#findComment-786957 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.