drillbitt Posted March 10, 2009 Share Posted March 10, 2009 Hey Guys, I have just upgraded a script, which as well as many other things is now php based as opposed to it being previously CGI The issue I have is, the script features a subscription option, which of couse submits not only to a different locatation now, but also has changed to php. i have migrated all my script users over to the new version, and whilst i have told them about updating the form codes on their pages, I wondered how I set up a permanent form-redirect cgi page, for those few optin forms that slip through the update? Bottom line is I want any form thats submitted to http://mysite.com/cgi-bin/optin.cgi to be re-directed (Or re-posted, not sure which syntax is correct!) to http://mysite.com/newscript/optin.php (All other details of the form are identical) Is this at all possible?? Cheers! Quote Link to comment https://forums.phpfreaks.com/topic/148821-solved-post-form-data-via-cgi-redirect-possible/ Share on other sites More sharing options...
rhodesa Posted March 10, 2009 Share Posted March 10, 2009 you should be able to use an htaccess file to rewrite /cgi-bin/optin.cgi to /newscript/optin.php Quote Link to comment https://forums.phpfreaks.com/topic/148821-solved-post-form-data-via-cgi-redirect-possible/#findComment-781498 Share on other sites More sharing options...
drillbitt Posted March 11, 2009 Author Share Posted March 11, 2009 Hi rhodesa Thanks for the reply Unfortunately my knowledge of using Htaccess files is REALLY limited... Can anyone point me in the right direction where I could get some more detail on creating this type of thing?? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/148821-solved-post-form-data-via-cgi-redirect-possible/#findComment-782355 Share on other sites More sharing options...
corbin Posted March 11, 2009 Share Posted March 11, 2009 Alias /cgi-bin/optin.cgi /newscript/optin.php You might need different paths though. Quote Link to comment https://forums.phpfreaks.com/topic/148821-solved-post-form-data-via-cgi-redirect-possible/#findComment-782401 Share on other sites More sharing options...
rhodesa Posted March 11, 2009 Share Posted March 11, 2009 Alias /cgi-bin/optin.cgi /newscript/optin.php You might need different paths though. If I remember right...the first path is the URL path of the old file and the second part is the Filesystem path of the new file Quote Link to comment https://forums.phpfreaks.com/topic/148821-solved-post-form-data-via-cgi-redirect-possible/#findComment-782422 Share on other sites More sharing options...
corbin Posted March 11, 2009 Share Posted March 11, 2009 Hrmmmm.... I was thinking that that is how it is in httpd.conf, but in .htaccess files, it's relative to the webroot. I'm probably remember incorrectly though ;p. Quote Link to comment https://forums.phpfreaks.com/topic/148821-solved-post-form-data-via-cgi-redirect-possible/#findComment-782445 Share on other sites More sharing options...
drillbitt Posted March 11, 2009 Author Share Posted March 11, 2009 I tried this : Redirect /home/username/public_html/cgi-bin/optin.cgi http://sitename.com/v2/ar/optin.php as the .htaccess file. based on the guidance given here: http://www.javascriptkit.com/howto/htaccess7.shtml I uploaded it to the root folder, but It didn't do anything at all, it allowed the cgi-bin/optin.cgi file to process the form. Did i miss something crucial?? EDIT: tried again and received a 500 error...any ideas?? Quote Link to comment https://forums.phpfreaks.com/topic/148821-solved-post-form-data-via-cgi-redirect-possible/#findComment-782496 Share on other sites More sharing options...
rhodesa Posted March 11, 2009 Share Posted March 11, 2009 redirect uses the HTTP Path for both...try this: Redirect /cgi-bin/optin.cgi http://sitename.com/v2/ar/optin.php Quote Link to comment https://forums.phpfreaks.com/topic/148821-solved-post-form-data-via-cgi-redirect-possible/#findComment-782546 Share on other sites More sharing options...
drillbitt Posted March 12, 2009 Author Share Posted March 12, 2009 COOL!! I think i'm almost there! The error has gone, and the .htaccess file is certainly redirecting the user to the new signup page as I wanted... I am however receiving an error message regarding the signup process (But at least this time its coming from the correct script!!) Heres the old code, along with the new, apart from the URL, I can't see any difference, but when i test it I receive an error message saying I'm using the wrong form to subscribe: Old Code: <script language="JavaScript"> function checkSub(){ if (document.signup.email.value.indexOf('@', 0) == -1) { alert("Please fill in your valid Email address.\nYour email should be in the following format: email@address.com") document.signup.email.focus() return false} if (document.signup.fname.value == "") { alert("Please fill in your First name.") document.signup.fname.focus() return false} }</script><form action="http://mysite.com/cgi-bin/ent/optin.cgi" method="post" name="signup" onsubmit="return checkSub()"><input type=hidden name="action" value="addlead"><input type=hidden name="member" value="1"><input type=hidden name="auto" value="1"><input type=hidden name="thankyou" value=""><table border=0 cellspacing=0 cellpadding=2><tr><td><font size="2" face="arial, verdana">First Name:</font></td><td><input type=text size=20 name="fname"></td></tr><tr><td><font size="2" face="arial, verdana">Email Address:</font></td><td><input type=text size=20 name="email"></td></tr><tr><td></td><td align=center><input type="submit" value="Subscribe"></td></tr></table></form> And the code generated by the new script is: <script language="JavaScript"> function checkSub(){ if (document.signup.email.value.indexOf('@', 0) == -1) { alert("Please fill in your valid Email address.\nYour email should be in the following format: email@address.com") document.signup.email.focus() return false} if (document.signup.fname.value == "") { alert("Please fill in your First name.") document.signup.fname.focus() return false} }</script><form action="http://mysite.com/v2/ar/optin.php" method="post" name="signup" onsubmit="return checkSub()"><input type=hidden name="action" value="addlead"><input type=hidden name="member" value="1"><input type=hidden name="auto" value="1"><input type=hidden name="thankyou" value=""><table border=0 cellspacing=0 cellpadding=2><tr><td><font size="2" face="arial, verdana">First Name:</font></td><td><input type=text size=20 name="fname"></td></tr><tr><td><font size="2" face="arial, verdana">Email Address:</font></td><td><input type=text size=20 name="email"></td></tr><tr><td></td><td align=center><input type="submit" value="Subscribe"></td></tr></table></form> I can't see any difference. Any idea what might be causing it? It feels like I'm SO close now! Quote Link to comment https://forums.phpfreaks.com/topic/148821-solved-post-form-data-via-cgi-redirect-possible/#findComment-782579 Share on other sites More sharing options...
rhodesa Posted March 12, 2009 Share Posted March 12, 2009 receiving an error message regarding the signup process and the error is? Quote Link to comment https://forums.phpfreaks.com/topic/148821-solved-post-form-data-via-cgi-redirect-possible/#findComment-782631 Share on other sites More sharing options...
drillbitt Posted March 12, 2009 Author Share Posted March 12, 2009 It directs to the new script, but the error message appears: Incorrect form Sorry but an error has occured. Please use the correct form to subscribe. It seems strange, because all the details of the form submission are the same, including all the identifiers... Quote Link to comment https://forums.phpfreaks.com/topic/148821-solved-post-form-data-via-cgi-redirect-possible/#findComment-782958 Share on other sites More sharing options...
rhodesa Posted March 12, 2009 Share Posted March 12, 2009 ok...so more digging around and it turns out redirects with apache drop the POST data. So, you need to use Rewrite: RewriteEngine On RewriteBase / RewriteRule /cgi-bin/optin.cgi /v2/ar/optin.php Quote Link to comment https://forums.phpfreaks.com/topic/148821-solved-post-form-data-via-cgi-redirect-possible/#findComment-782997 Share on other sites More sharing options...
drillbitt Posted March 12, 2009 Author Share Posted March 12, 2009 Hey Aaron, Do I save that as the same .htaccess type file? Sorry if thats a daft question, my learning curve on this subject is almost vertical, so thanx for your patience! Quote Link to comment https://forums.phpfreaks.com/topic/148821-solved-post-form-data-via-cgi-redirect-possible/#findComment-783014 Share on other sites More sharing options...
drillbitt Posted March 12, 2009 Author Share Posted March 12, 2009 I tried adding the code as specified and uploaded as .htaccess file When I completed the form it subscribed me to the old version of the script and seemed to ignore the new one completely. Thanks again for your help on this one! Quote Link to comment https://forums.phpfreaks.com/topic/148821-solved-post-form-data-via-cgi-redirect-possible/#findComment-783050 Share on other sites More sharing options...
rhodesa Posted March 12, 2009 Share Posted March 12, 2009 hum...try with the htaccess file in: /home/username/public_html/cgi-bin/.htaccess RewriteEngine On RewriteBase /cgi-bin/ RewriteRule optin.cgi /v2/ar/optin.php Quote Link to comment https://forums.phpfreaks.com/topic/148821-solved-post-form-data-via-cgi-redirect-possible/#findComment-783055 Share on other sites More sharing options...
drillbitt Posted March 12, 2009 Author Share Posted March 12, 2009 YES!! - Aaron You Are A Total Diamond!! Thankyou so much! Quote Link to comment https://forums.phpfreaks.com/topic/148821-solved-post-form-data-via-cgi-redirect-possible/#findComment-783074 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.