Jump to content

Recommended Posts

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?

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.

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); 
}
?> 

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.