PHP interesse |
|
Kben dus bezig met een soorrt register-pagina maar
voor je kan registreren moet de ingevuld code correct zijn bla bla..
deze zit in een image verborgen
dit bestand heb ik image.php genoemd.
nu voeg ik deze image toe op de andere pagina
via <img src="image.php"> maar nu heb ik een probleem..
ik moet de variabelen wat in de image zitten kunnen gebruiken want
anders kan ik nie checken of de code juist is..
ik probeerd al met cookies.. dat hij deze wegschrijft en trg probeert te lezen
maar dat doet hij mr niet..
iemand enig idee ?
image.php ->
<?
function strrnd($len=8,$num=True) {
mt_srand(microtime() * 1000000);
for($password='';strlen($password)<$len;){
if (!mt_rand(0,2) && $num) {
$password.=chr(mt_rand(48,57));
} else if (!mt_rand(0,1)) {
$password.=chr(mt_rand(65,90));
} else {
$password.=chr(mt_rand(97,122));
}
}
return $password;
}
if(isset($_COOKIE["generated"]))
{
echo "wait a minute before adding another gallery";
}
else
{
$password = strrnd(6);
$imgTXT = $password; //tekst die op de afbeelding komt
$imgCreate = ImageCreate(90, 45); //breedte, hoogte
$imgBg = ImageColorAllocate($imgCreate, 255, 228, 181); //255, 255, 255 is wit (achtergrond)
$imgFg = ImageColorAllocate($imgCreate, 25, 25, 112); //51, 51, 51 is zwart (textkleur)
ImageFill($imgCreate, 1, 1, $imgBg);
ImageString($imgCreate, 10, 1, 15, " " .$imgTXT, $imgFg);
header('Content-type: image/png');
ImagePNG($imgCreate);
ImageDestroy($imgCreate);
setcookie("generated",$password,time()+ 60 * 60, '/');
}
?>
<? function strrnd($len=8,$num=True) { for($password='';strlen($password)<$len;){ } else { } } return $password; } if(isset($_COOKIE["generated"])) { echo "wait a minute before adding another gallery"; } else { $password = strrnd(6); $imgTXT = $password; //tekst die op de afbeelding komt $imgCreate = ImageCreate(90, 45); //breedte, hoogte $imgBg = ImageColorAllocate($imgCreate, 255, 228, 181); //255, 255, 255 is wit (achtergrond) $imgFg = ImageColorAllocate($imgCreate, 25, 25, 112); //51, 51, 51 is zwart (textkleur) ImageFill($imgCreate, 1, 1, $imgBg); ImageString($imgCreate, 10, 1, 15, " " .$imgTXT, $imgFg); header('Content-type: image/png'); ImagePNG($imgCreate); ImageDestroy($imgCreate); } ?>
een deel uit het ander bestand...
<body>
<font face="Verdana" size="1">
<form method="POST" action="">
<table border="0" width="100%" id="table1">
<font face="Verdana" size="2"><strong>Gallerydump</strong></font><br /><br />
<hr>
<br />
<?
if(isset($submit)){
$password = $_COOKIE['generated'];
$name = $_POST['name'];
$email = $_POST['email'];
$gallname = $_POST['gallname'];
$description = $_POST['description'];
$link = $_POST['link'];
$code = $_POST['code'];
if(empty($name)){
$error .= "<li>Please enter your name</li><br />";
}
if(empty($_POST['email']) || !eregi('@',$_POST['email']) || !eregi('.',$_POST['email']) || eregi(' ',$_POST['email'])){
$error .= " <li> Incorrect e-mailadres. </li><br />";
}
if(empty($gallname)){
$error .= "<li>Please give us the galleryname</li><br />";
}
if(empty($description)){
$error .= "<li>Please give us the discription of the galleryname</li><br />";
}
if(empty($link)){
$error .= "<li>Please enter the gallery-URL</li><br />";
}
if(empty($code)){
$error .= "<li>Please enter the code</li><br />";
}
if($error == NULL){
if($code != $password){
$error .= "<li>Please enter the correct code</li><br />";
echo $error;
}else{
echo "alles in orde nu invoegen e..";
}
}
else
{
echo $error;
}
}
?>
<tr>
<td width="178">Your name:</td>
<td><input type="text" name="name" size="27"></td>
</tr>
<tr>
<td width="178">Your e-mail:</td>
<td><input type="text" name="email" size="27"></td>
</tr>
<tr>
<td width="178">Galleryname:</td>
<td><input type="text" name="gallname" size="27"></td>
</tr>
<tr>
<td width="178">Description:</td>
<td><textarea rows="5" name="description" cols="21"></textarea></td>
</tr>
<tr>
<td width="178">URL to gallery:
http://</td>
<td><input type="text" name="link" size="27"></td>
</tr>
<tr>
<td width="178"><img src="image.php" border="0" alt="" title="Enter this text in the textbox. This is just a security against badscripts">
</td>
<td><input type="text" name="code" size="27"></td>
</tr>
</table>
<p><input type="submit" value="Verzenden" name="submit"><input type="reset" value="Invoer wissen" name="reset"></p>
</form>
</body>
</html>
<body> <font face="Verdana" size="1"> <form method="POST" action=""> <table border="0" width="100%" id="table1"> <font face="Verdana" size="2"><strong>Gallerydump</strong></font><br /><br /> <hr> <br /> <? $password = $_COOKIE['generated']; $name = $_POST['name']; $email = $_POST['email']; $gallname = $_POST['gallname']; $description = $_POST['description']; $link = $_POST['link']; $code = $_POST['code']; $error .= "<li>Please enter your name</li><br />"; } if(empty($_POST['email']) || !eregi('@',$_POST['email']) || !eregi('.',$_POST['email']) || eregi(' ',$_POST['email'])){ $error .= " <li> Incorrect e-mailadres. </li><br />"; } $error .= "<li>Please give us the galleryname</li><br />"; } $error .= "<li>Please give us the discription of the galleryname</li><br />"; } $error .= "<li>Please enter the gallery-URL</li><br />"; } $error .= "<li>Please enter the code</li><br />"; } if($error == NULL){ if($code != $password){ $error .= "<li>Please enter the correct code</li><br />"; }else{ echo "alles in orde nu invoegen e.."; } } else { } } ?> <tr> <td width="178">Your name:</td> <td><input type="text" name="name" size="27"></td> </tr> <tr> <td width="178">Your e-mail:</td> <td><input type="text" name="email" size="27"></td> </tr> <tr> <td width="178">Galleryname:</td> <td><input type="text" name="gallname" size="27"></td> </tr> <tr> <td width="178">Description:</td> <td><textarea rows="5" name="description" cols="21"></textarea></td> </tr> <tr> <td width="178">URL to gallery: http://</td> <td><input type="text" name="link" size="27"></td> </tr> <tr> <td width="178"><img src="image.php" border="0" alt="" title="Enter this text in the textbox. This is just a security against badscripts"> </td> <td><input type="text" name="code" size="27"></td> </tr> </table> <p><input type="submit" value="Verzenden" name="submit"><input type="reset" value="Invoer wissen" name="reset"></p> </form> </body> </html>
|