Captcha wordt geresized
ik ben bezig met een spel in PHP voor mijn profielwerkstuk maar nu kwam ik een erg merkwaardige fout tegen. ik wilde ene captcha toevoegen maar die wordt geresized, hierdoor kreeg je een langgerekte en niet echt mooie afbeelding
dit is de code van de captcha
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
session_start();
//imagecreatefrompng :: create a new image
//from file or URL
$img = imagecreatefrompng('black.png');
//displaying the random text on the captcha
$numero = rand(10000, 99999);
$_SESSION['check'] = ($numero);
//The function imagecolorallocate creates a
//color using RGB (red,green,blue) format.
$white = imagecolorallocate($img, 255, 255, 255);
imagestring($img, 10, 8, 5, $numero, $white);
header ("Content-type: image/png"); imagepng($img);
?>
session_start();
//imagecreatefrompng :: create a new image
//from file or URL
$img = imagecreatefrompng('black.png');
//displaying the random text on the captcha
$numero = rand(10000, 99999);
$_SESSION['check'] = ($numero);
//The function imagecolorallocate creates a
//color using RGB (red,green,blue) format.
$white = imagecolorallocate($img, 255, 255, 255);
imagestring($img, 10, 8, 5, $numero, $white);
header ("Content-type: image/png"); imagepng($img);
?>
en die van de pagina waarop die wordt gebruikt
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
session_start();
if(isset($_SESSION['id']) and isset($_SESSION['username']))//kijk of de bij het inloggen gecreëerde sessie niet kan worden teruggehaald
{
header("location:overview.php"); //verwijs door naar de overzichtspagina
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>overview</title>
<link href="stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="maindiv">
<div id="menu">
<a href="index.htm" class="menu">Home</a><br /><br />
<a href="login.php" class="menu">log in</a><br /><br />
<a href="registration.php" class="menu">register now!</a><br /><br />
<a href="activation.php" class="menu">activate now!</a><br /><br />
</div>
<div id="content">
<?php
if(isset($_GET["error"]))
{
switch($_GET["error"])
{
case 0: echo "unable to connect with database.<br />";
break;
case 1: echo "please fill in all fields.<br />";
break;
case 2: echo "your passwords do not match.<br />";
break;
case 3: echo "your email is invalid.<br />";
break;
case 4: echo "your username is invalid, please only use letters, digits or spaces.<br />";
break;
case 5: echo "your username must be at least 6 characters.<br />";
break;
case 6: echo "your password must be at least 6 characters.<br />";
break;
case 7: echo "username already in use.<br />";
break;
case 8: echo "email already in use.<br />";
break;
case 9: echo "unable to generate an activation code.<br />";
break;
case 10: echo "unable to store data on the database.<br />";
break;
case 11: echo "unable to send an activation mail.<br />";
break;
}
}
if(isset($_GET["registred"]))
{
echo "registration completed. check your mail for activation<br />";
}
?>
fill in the fields to receive an email with your password<br />
<center>
<table>
<form action="registration2.php" method="post" accept-charset='UTF8'>
<tr><td>Username: </td><td><input type="text" name="username" maxlength="25"/></td></tr>
<tr><td>Password: </td><td><input type="password" name="password" maxlength="25"/></td></tr>
<tr><td>Verify Password: </td><td><input type="password" name="password2" maxlength="25"/><br /></td></tr>
<tr><td>Email: </td><td><input type="text" name="email" maxlength="100"/></td></tr>
<img src="captcha.php" />
<tr><td>neem de tekens over: </td><td><input type="text" size="5" name="check"></td></tr>
</table>
<input type="submit" />
</form>
</center>
</div>
</div>
</body>
</html>
session_start();
if(isset($_SESSION['id']) and isset($_SESSION['username']))//kijk of de bij het inloggen gecreëerde sessie niet kan worden teruggehaald
{
header("location:overview.php"); //verwijs door naar de overzichtspagina
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>overview</title>
<link href="stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="maindiv">
<div id="menu">
<a href="index.htm" class="menu">Home</a><br /><br />
<a href="login.php" class="menu">log in</a><br /><br />
<a href="registration.php" class="menu">register now!</a><br /><br />
<a href="activation.php" class="menu">activate now!</a><br /><br />
</div>
<div id="content">
<?php
if(isset($_GET["error"]))
{
switch($_GET["error"])
{
case 0: echo "unable to connect with database.<br />";
break;
case 1: echo "please fill in all fields.<br />";
break;
case 2: echo "your passwords do not match.<br />";
break;
case 3: echo "your email is invalid.<br />";
break;
case 4: echo "your username is invalid, please only use letters, digits or spaces.<br />";
break;
case 5: echo "your username must be at least 6 characters.<br />";
break;
case 6: echo "your password must be at least 6 characters.<br />";
break;
case 7: echo "username already in use.<br />";
break;
case 8: echo "email already in use.<br />";
break;
case 9: echo "unable to generate an activation code.<br />";
break;
case 10: echo "unable to store data on the database.<br />";
break;
case 11: echo "unable to send an activation mail.<br />";
break;
}
}
if(isset($_GET["registred"]))
{
echo "registration completed. check your mail for activation<br />";
}
?>
fill in the fields to receive an email with your password<br />
<center>
<table>
<form action="registration2.php" method="post" accept-charset='UTF8'>
<tr><td>Username: </td><td><input type="text" name="username" maxlength="25"/></td></tr>
<tr><td>Password: </td><td><input type="password" name="password" maxlength="25"/></td></tr>
<tr><td>Verify Password: </td><td><input type="password" name="password2" maxlength="25"/><br /></td></tr>
<tr><td>Email: </td><td><input type="text" name="email" maxlength="100"/></td></tr>
<img src="captcha.php" />
<tr><td>neem de tekens over: </td><td><input type="text" size="5" name="check"></td></tr>
</table>
<input type="submit" />
</form>
</center>
</div>
</div>
</body>
</html>
het vreemdste is dat in alle pagina´s in de map op mijn server dit probleem zich voordoet, maar in de main map, waar mijn eigen website staat, niet voor mijn profielwerkstuk, gebruik ik dezelfde captcha maar geeft dit geen problemen
heeft iemand een idee hoe dit kan?
Gewijzigd op 06/02/2012 20:54:08 door Marijn Struijlaart
Kan het nog te maken hebben met je css??
oeps zie nu pas dat ik algemene breedte heb gegeven voor img omdat dat toch mn enige afbeeldingen waren. dom van me. ga het nu aanpassen