jamesloo48 Posted March 4, 2010 Share Posted March 4, 2010 My psychometric testing script that has worked for many years at http://psychometric.mastersoequity.com has suddenly stopped working. The script is enclosed below: <!---The Form---> <? function display_form() { global $PHP_SELF; ?> <FORM TARGET="<?php echo $PHP_SELF; ?>" METHOD="GET"> <br> <b>Name:</b> <INPUT TYPE=TEXT NAME="name"><BR> <br><br> 1) The Need To Succeed Is Very Important To You:<br> <INPUT TYPE=CHECKBOX NAME="no[]" VALUE="1">No <INPUT TYPE=CHECKBOX NAME="sometimes[]" VALUE="1">Sometimes <INPUT TYPE=CHECKBOX NAME="yes[]" VALUE="1">Yes <br><br> 2) To others, you are a man who can't keep his cool during a crisis:<br> <INPUT TYPE=CHECKBOX NAME="no[]" VALUE="1">No <INPUT TYPE=CHECKBOX NAME="sometimes[]" VALUE="1">Sometimes <INPUT TYPE=CHECKBOX NAME="yes[]" VALUE="1">Yes <br><br> 3) You believe that living now is more stressful than during your dad's time:<br> <INPUT TYPE=CHECKBOX NAME="no[]" VALUE="1">No <INPUT TYPE=CHECKBOX NAME="sometimes[]" VALUE="1">Sometimes <INPUT TYPE=CHECKBOX NAME="yes[]" VALUE="1">Yes <br><br> 4) Weekends is a time to give more thought to the work to come:<br> <INPUT TYPE=CHECKBOX NAME="no[]" VALUE="1">No <INPUT TYPE=CHECKBOX NAME="sometimes[]" VALUE="1">Sometimes <INPUT TYPE=CHECKBOX NAME="yes[]" VALUE="1">Yes <br><br> 5) You feel more frustrated than bored during a traffic jam.:<br> <INPUT TYPE=CHECKBOX NAME="no[]" VALUE="1">No <INPUT TYPE=CHECKBOX NAME="sometimes[]" VALUE="1">Sometimes <INPUT TYPE=CHECKBOX NAME="yes[]" VALUE="1">Yes <br><br> 6) You never feel angry or frustrated at yourself when things don't go well, or as you have expected it to be:<br> <INPUT TYPE=CHECKBOX NAME="no[]" VALUE="1">No <INPUT TYPE=CHECKBOX NAME="sometimes[]" VALUE="1">Sometimes <INPUT TYPE=CHECKBOX NAME="yes[]" VALUE="1">Yes <br><br> <INPUT TYPE=HIDDEN NAME="stage" VALUE="results"> <INPUT TYPE=SUBMIT VALUE="Analyse Me!"> </FORM> <? } ?> <!---The Processor---> <? function process_form() { global $name; global $no; global $yes; global $sometimes; $no_times = count($no); $yes_times = count($yes); $sometimes_times = count($sometimes); if ($no_times > $yes_times && $no_times > $sometimes_times) { $analysis = 'result1 here'; } elseif ($no_times + $sometimes_times >= $yes_times) { $analysis = 'result2 here'; } else { $analysis = 'result3 here'; } print "<html><body><center>"; print "<b><font size=+1>$name</font></b>,<br><br><br>"; print "<p align=left>$analysis<br>"; print "</body></html>"; } ?> <? if (empty($stage)) { display_form(); } else { process_form(); } ?> Anyone help? Quote Link to comment https://forums.phpfreaks.com/topic/194121-script-that-has-worked-for-years-suddenly-stopped-working/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 4, 2010 Share Posted March 4, 2010 A) Ask your web host to publish information in their FAQ section exactly what php.ini configuration changes they just changed so that the customers would have a chance at finding all the things they need to update in their scripts. I am amazed at the number of web hosts that make changes to the server configuration and don't bother to notify their customers what they changed (of course some web hosts don't even know that they made such a change.) B) It appears that one of the things they changed was to finally turn off register_globals. Register_globals were actually turned off by default almost 8 years ago, but a lot of web hosts did a great disservice to their customers by leaving it on. Had they turned it off, you would not be having a problem today because all the existing scripts that relied on register_globals would have either been updated or would have disappeared long ago and new scripts would have not have relied on them. Short answer - register_globals magically populated program variables from the actual $_POST, $_GET, $_COOKIE, $_SESSION, $_FILES, $_SERVER, and $_ENV variables where the data comes from. Because this overwrites same named variables and it also back-populates $_SESSION variables it allows hackers to magically set $_SESSION variables and a lot of sites have been taken over (this allows hackers to become logged in as administrators to scripts and it also allows hackers to change configuration variables in code that then gets the hackers php code to be included into a file instead of the intended code.) So things like $PHP_SELF (which actually comes from $_SERVER['PHP_SELF']) and your form data, like $name (which actually comes from $_GET['name']) are no longer being set and you need to use the correct $_POST, $_GET, $_COOKIE, $_SESSION, $_FILES, $_SERVER, and $_ENV variables in your code. You should also change any <? tags to <?php and any <?= tags to <?php echo to avoid problems that short_open tags either are or will cause in your code. Quote Link to comment https://forums.phpfreaks.com/topic/194121-script-that-has-worked-for-years-suddenly-stopped-working/#findComment-1021378 Share on other sites More sharing options...
JonnoTheDev Posted March 4, 2010 Share Posted March 4, 2010 register_globals = bad, bad, bad Get your script updated in the manor PFMaBiSmAd has stated Quote Link to comment https://forums.phpfreaks.com/topic/194121-script-that-has-worked-for-years-suddenly-stopped-working/#findComment-1021380 Share on other sites More sharing options...
jamesloo48 Posted March 4, 2010 Author Share Posted March 4, 2010 Could anyone help by posting a corrected version of my script above please? Help is deeply appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/194121-script-that-has-worked-for-years-suddenly-stopped-working/#findComment-1021389 Share on other sites More sharing options...
JonnoTheDev Posted March 4, 2010 Share Posted March 4, 2010 Here you go. This is a very weak script and needs a lot of improvement, however I will leave that upto you. This should work. <!---The Form---> <?php function display_form() { ?> <FORM TARGET="<?php echo $_SERVER['PHP_SELF']; ?>" METHOD="POST"> <br> <b>Name:</b> <INPUT TYPE=TEXT NAME="name"><BR> <br><br> 1) The Need To Succeed Is Very Important To You:<br> <INPUT TYPE=CHECKBOX NAME="no[]" VALUE="1">No <INPUT TYPE=CHECKBOX NAME="sometimes[]" VALUE="1">Sometimes <INPUT TYPE=CHECKBOX NAME="yes[]" VALUE="1">Yes <br><br> 2) To others, you are a man who can't keep his cool during a crisis:<br> <INPUT TYPE=CHECKBOX NAME="no[]" VALUE="1">No <INPUT TYPE=CHECKBOX NAME="sometimes[]" VALUE="1">Sometimes <INPUT TYPE=CHECKBOX NAME="yes[]" VALUE="1">Yes <br><br> 3) You believe that living now is more stressful than during your dad's time:<br> <INPUT TYPE=CHECKBOX NAME="no[]" VALUE="1">No <INPUT TYPE=CHECKBOX NAME="sometimes[]" VALUE="1">Sometimes <INPUT TYPE=CHECKBOX NAME="yes[]" VALUE="1">Yes <br><br> 4) Weekends is a time to give more thought to the work to come:<br> <INPUT TYPE=CHECKBOX NAME="no[]" VALUE="1">No <INPUT TYPE=CHECKBOX NAME="sometimes[]" VALUE="1">Sometimes <INPUT TYPE=CHECKBOX NAME="yes[]" VALUE="1">Yes <br><br> 5) You feel more frustrated than bored during a traffic jam.:<br> <INPUT TYPE=CHECKBOX NAME="no[]" VALUE="1">No <INPUT TYPE=CHECKBOX NAME="sometimes[]" VALUE="1">Sometimes <INPUT TYPE=CHECKBOX NAME="yes[]" VALUE="1">Yes <br><br> 6) You never feel angry or frustrated at yourself when things don't go well, or as you have expected it to be:<br> <INPUT TYPE=CHECKBOX NAME="no[]" VALUE="1">No <INPUT TYPE=CHECKBOX NAME="sometimes[]" VALUE="1">Sometimes <INPUT TYPE=CHECKBOX NAME="yes[]" VALUE="1">Yes <br><br> <INPUT TYPE=HIDDEN NAME="stage" VALUE="results"> <INPUT TYPE=SUBMIT VALUE="Analyse Me!"> </FORM> <?php } ?> <!---The Processor---> <?php function process_form($values) { $no_times = count($values['no']); $yes_times = count($values['yes']); $sometimes_times = count($values['sometimes']); if($no_times > $yes_times && $no_times > $sometimes_times) { $analysis = 'result1 here'; } elseif($no_times + $sometimes_times >= $yes_times) { $analysis = 'result2 here'; } else { $analysis = 'result3 here'; } print "<html><body><center>"; print "<b><font size=+1>".$values['name']."</font></b>,<br><br><br>"; print "<p align=left>".$analysis."<br>"; print "</body></html>"; } ?> <?php if(empty($_POST['stage'])) { display_form(); } else { process_form($_POST); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/194121-script-that-has-worked-for-years-suddenly-stopped-working/#findComment-1021393 Share on other sites More sharing options...
jamesloo48 Posted March 4, 2010 Author Share Posted March 4, 2010 Thank you Neil for taking the time to correct the codes. I tried the corrections and uploaded it to http://psychometric.mastersoequity.com but the form still didn't process the form and returned the form itself again after submitting... any idea? Quote Link to comment https://forums.phpfreaks.com/topic/194121-script-that-has-worked-for-years-suddenly-stopped-working/#findComment-1021397 Share on other sites More sharing options...
PFMaBiSmAd Posted March 4, 2010 Share Posted March 4, 2010 The actual form method is get Quote Link to comment https://forums.phpfreaks.com/topic/194121-script-that-has-worked-for-years-suddenly-stopped-working/#findComment-1021398 Share on other sites More sharing options...
jamesloo48 Posted March 4, 2010 Author Share Posted March 4, 2010 OH!!!! THATS RIGHT!!! I changed the "POST"s to "GET"s and its working again now!!! HURRAY!!! THANKS A LOT GUYS!!!! Quote Link to comment https://forums.phpfreaks.com/topic/194121-script-that-has-worked-for-years-suddenly-stopped-working/#findComment-1021405 Share on other sites More sharing options...
JonnoTheDev Posted March 4, 2010 Share Posted March 4, 2010 The actual form method is get I changed it to post seen as its using arrays. You may have copied the code to quick. Did a few adjustments. Try again. Quote Link to comment https://forums.phpfreaks.com/topic/194121-script-that-has-worked-for-years-suddenly-stopped-working/#findComment-1021406 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.