ich musste den beitrag jetzt 5 mal lesen um ihn zu kapieren.
ich glaube du meinst ich sollte um mich abzusichern die $PHPSESSID mit übergeben um sicherzustellen das kein Script action.php so einfach überlisten kann, so als zweite absicherung!?
dann würde das so aussehen:
index.php:
<?php
SESSION_START();
?>
<FORM METHOD="POST" ACTION="action.php">
<INPUT TYPE="hidden" NAME="sid" VALUE="<?php echo $PHPSESSID; ?>">
<TABLE>
<TR>
<TD>Username</TD>
<TD><INPUT TYPE="text" NAME="usr"></TD>
</TR>
<TR>
<TD>Ect</TD>
<TD><INPUT TYPE="text" NAME="ect"></TD>
</TR>
<TR>
<TD>Sicherheits-Code</TD>
<TD><INPUT TYPE="text" NAME="sc"></TD>
</TR>
<TR>
<TD></TD>
<TD><INPUT TYPE="submit"></TD>
</TR>
</TABLE>
</FORM>
<IMG SRC="bild.php" BORDER="0" ALT="Sicherheits-Code">
--
bild.php:
<?
SESSION_START();
Textposition
$tx = 9;
$ty = 7;
Dimension
$MaxX = 70;
$MaxY = 30;
Bild erstellen
header("Content-type: image/png");
$im = @imagecreate($MaxX,$MaxY);
Farben definieren
$white = @ImageColorAllocate($im, 255,255,255);
$red = @ImageColorAllocate($im, 255,0,0);
$green = @ImageColorAllocate($im, 0,255,0);
$gray = @ImageColorAllocate($im, 128,128,128);
$lightgray = @ImageColorAllocate($im, 224,224,224);
$lightblue = @ImageColorAllocate($im, 128,128,255);
@ImageColorTransparent($im, $white); # weiß = transparent
$tcol = explode(",",$tcolor);
$text_color = @ImageColorAllocate($im, $tcol[0], $tcol[1], $tcol[2]);
$bcol = explode(",",$bcolor);
$border_color = @ImageColorAllocate($im, $bcol[0], $bcol[1], $bcol[2]);
$strng='';
for ($i=1; $i<=6;) # Anzahl der Zeichen
{
mt_srand((double)microtime()*1000000);
$char = mt_rand(48,122);
if($char>47 && $char<58 || $char>64 && $char<91 || $char>96 && $char<123)
{
$strng.=chr($char);
$i++;
}
}
$_SESSION['bildsid']=$PHPSESSID;
$_SESSION['secure']=$strng;
@imagefill($im, 0, 0, $lightgray);
Rahmen und Logo setzen
@imagerectangle($im, 0, 0, $MaxX-1, $MaxY-1, $border_color);
@imagestring($im, 5, $tx, $ty, $strng, $text_color);
@imagepng($im);
?>
--
action.php:
<?php
SESSION_START();
$secure=$_SESSION['secure'];
$bildsid=$_SESSION['bildsid'];
if($usr=='')$stop=true;
if($ect=='')$stop=true;
if($sid!=$bildsid)$stop=true;
if($sc!=$secure)$stop=true;
if($stop!=true)
{
$qry = "INSERT INTO usrtbl (usr, ect) VALUES('$usr', '$ect')";
print $qry; // :-)
}
else print "na stimmt was nicht :-o<br>";
?>
so kontrolliere ich ausserdem das man meinen link benutzt.
aber die SESSION_START(); in action.php brauche ich doch.
MfG Ulf