Jump to content

Session problems or something else


cmgmyr

Recommended Posts

I have a users page that has this in it:

[code=php:0]function GetRandomChar() {
mt_srand((double)microtime()*1000000);
$IMGVER_RandVal = mt_rand(1,3);

switch ($IMGVER_RandVal) {
case 1:
$IMGVER_RandVal = mt_rand(97, 122);
break;
case 2:
$IMGVER_RandVal = mt_rand(48, 57);
break;
case 3:
$IMGVER_RandVal = mt_rand(65, 90);
break;
}
return chr($IMGVER_RandVal);
}
function register_form(){
        global $db, $prefix, $name, $email, $username, $password, $user_taken_err, $email_taken_err, $name_taken_err, $type;
if($type == "f"){
$nameout = "Your";
}elseif($type == "b"){
$nameout = "Band";
}else{
$nameout = "Your";
$type = "f";
}

session_start();

$IMGVER_TempString="";

for ($i = 1; $i <= 6; $i++) {
  $IMGVER_TempString .= GetRandomChar();
}

$HTTP_SESSION_VARS["IMGVER_RndText"] = $IMGVER_TempString;
$IMGVER_RandomText = $HTTP_SESSION_VARS["IMGVER_RndText"];

echo "<div style=\"text-align:center;\"><span class=\"title\">Registration form</span><br />";
echo "Fields marked with a * are required.
      <form id=\"RegisterForm\" method=\"post\" action=\"users.php\">
      <table style=\"margin:0 auto;width:400px;\" border=\"0\" id=\"table1\" cellpadding=\"2\">
<tr>
<td style=\"text-align:right;width:50%;\">$nameout Name:</td>
<td style=\"text-align:left;width:50%;\"><input type=\"text\" name=\"name\" size=\"20\" value=\"$name\" /> * $name_taken_err</td>
</tr>
<tr>
  <td style=\"text-align:right;\">E-Mail:</td>
  <td style=\"text-align:left;\"><input type=\"text\" name=\"email\" size=\"20\" value=\"$email\" /> * $email_taken_err</td>
    </tr>
<tr>
  <td style=\"text-align:right;\">&nbsp;</td>
  <td>&nbsp;</td>
    </tr>
<tr>
<td style=\"text-align:right;\">Username:</td>
<td style=\"text-align:left;\"><input type=\"text\" name=\"username\" size=\"18\" value=\"$username\" /> * $user_taken_err</td>
</tr>
<tr>
<td style=\"text-align:right;\">Password:</td>
<td style=\"text-align:left;\"><input type=\"password\" name=\"password\" size=\"18\" value=\"$password\" /> *</td>
</tr>
<tr>
  <td align=\"right\">Verify Image:</td>
  <td align=\"left\"><img src=\"doimg.php?"; echo SID."\" /><br /><input name=\"verify\" type=\"text\" id=\"verify\"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type=\"submit\" value=\"Register\" />
<input type=\"hidden\" name=\"cmg\" value=\"do_Register\" />
<input type=\"hidden\" name=\"type\" value=\"$type\" /></td>
</tr>
</table></form>[ <a href=\"users.php\" title=\"Back\">Back</a> ]</div>";
}[/code]


here is doimg.php

[code=php:0]<?php
$IMGVER_IMAGE = imagecreate(150,40);

$IMGVER_COLOR_BLACK = imagecolorallocate ($IMGVER_IMAGE, 0, 0, 0);
$IMGVER_COLOR_WHITE = imagecolorallocate ($IMGVER_IMAGE, 255, 255, 255);

imagefill($IMGVER_IMAGE, 0, 0, $IMGVER_COLOR_BLACK);

session_start();
$IMGVER_RandomText = $HTTP_SESSION_VARS["IMGVER_RndText"];

imagechar($IMGVER_IMAGE, 4, 20, 13, $IMGVER_RandomText[0] ,$IMGVER_COLOR_WHITE);
imagechar($IMGVER_IMAGE, 5, 40, 13, $IMGVER_RandomText[1] ,$IMGVER_COLOR_WHITE);
imagechar($IMGVER_IMAGE, 3, 60, 13, $IMGVER_RandomText[2] ,$IMGVER_COLOR_WHITE);
imagechar($IMGVER_IMAGE, 4, 80, 13, $IMGVER_RandomText[3] ,$IMGVER_COLOR_WHITE);
imagechar($IMGVER_IMAGE, 5, 100, 13, $IMGVER_RandomText[4] ,$IMGVER_COLOR_WHITE);
imagechar($IMGVER_IMAGE, 3, 120, 13, $IMGVER_RandomText[5] ,$IMGVER_COLOR_WHITE);

header("Content-type: image/jpeg");
imagejpeg($IMGVER_IMAGE);
?>[/code]

I have used this same thing on a contact page and it works fine. When I go to register now there is just a blank black box. When I go to the contact page, that image loads fine, when I go back to register the same code appears as the contact page I was just on.

Am I missing something? Do you need any other code to look at?

Thanks,
-Chris
Link to comment
https://forums.phpfreaks.com/topic/17024-session-problems-or-something-else/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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