RE: [PHP] Why isn't this working? :(
| From: | Martin Towell | Date: | Tue, 23 Apr 2002 01:18:07 +0000 |
| Subject: | RE: [PHP] Why isn't this working? :( | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-94094@lists.php.net to get a copy of this message | ||
> Can someone try to figure out what's wrong with my code?
What are you expecting, and what are you seeing?
-----Original Message-----
From: Leif K-Brooks [mailto:eurleif@buyer-brokerage.com]
Sent: Tuesday, April 23, 2002 11:12 AM
To: php-general@lists.php.net
Subject: [PHP] Why isn't this working? :(
I have a site where users can sign up. I have had huge problems with people
using auto-signups, so I tried to stop them with an authentication image.
Someone has since gotten around that. I highly doubt he is using OCR. Can
someone try to figure out what's wrong with my code? Here it is:
Contents of auth_image.php:
<?php
$dbh = mysql_connect ("MYSERVER", "MYUSER", "MYPASS");
mysql_select_db ("MYDB",$dbh);
$authimage = ImageCreate(40,15);
$white = ImageColorAllocate($authimage, 255, 255, 255);
$black = ImageColorAllocate($authimage, 0, 0, 0);
header("Content-type: image/jpeg");
$getcode = mysql_fetch_array(mysql_query("select * from signupcodes where id
= '$id'"));
imagestring($authimage,5,0,0,$getcode[code],$black);
imagejpeg($authimage);
imagedestroy($authimage);
?>
Some code from signup.php:
//I do seed the random number in the header
$code = mt_rand(1000,9999);
mysql_query("insert into signupcodes(code) values('$code')");
$codeid = mysql_insert_id();
<input type=hidden name=codeid value=$codeid><img
src='authimage.php?id=$codeid'><br>
<b>Code from above:</b> <input type=text name=code><br>
At top of proccess_signup.php:
$getcode = mysql_fetch_array(mysql_query("select * from signupcodes where id
= '$codeid'"));
if($code != $getcode[code]){
die("<b>Error:</b> wrong code");
}
In the middle of process_signup.php, after I've done checks of a few other
things:
echo "You're a member! :D<br><a href='/'>Back to
homepage</a>";
mysql_query("delete from signupcodes where id='$codeid'") or print