Hi,
Please i'm writing a code to generate a code foe the user to enter and submit..the process work fine but when i use imageline() function to
to generate a distort line to make the random numbers loop a bit difficult, it does not work
I mean the image line i added does not make the code work at all and even the codes not show but when i comment out the
imagelin() part then it works..please here is the code and help fix the imageline() part for me..i have generate.php page and index.php page
under generate.[php] page code here
[<?php]
session_start();
header('content-type: image/jpeg');
//we first need to stored it in a session
$text=$_SESSION['secure'];
$font_size=30; //after storing it in a session,we give a font size
$image_width=130; //we then find the image width and the image height
$image_height=40;
//we the n create our image using imagecreate function
$image=imagecreate($image_width,$image_height);
//we then give the bgcolor and the font color for the image using a function called imagecolorallocate
imagecolorallocate($image,255,255,255);
$font_color=imagecolorallocate($image,0,0,0);
//here i will use imageline function to add a little distort to the image to make it difficult to read
//i will use for loop to achiev that
for($x=0; $x<=30, $x++){
$x1=rand(1,100);
$y1=rand(1,100);
$x2=rand(1,100);
$y2=rand(1,100);
imageline($image,$x1,$y1,$x2,$y2,$font_color);
}
//we then also use a function called imagettftext function which takes 10 arqument.
imagettftext($image,$font_size,0,15,35,$font_color,'font.ttf',$text);
imagejpeg($image);
[?>]
under index.[php] code here
[<?php]
session_start();
if(!isset($_SESSION['secure'])){
$_SESSION['secure']=rand(1000,9999);
}else if($_SESSION['secure']==$_GET['secure']){
echo 'A match';
}else{
echo 'incorrect code,try again';
$_SESSION['secure']=rand(1000,9999);
}
[?>]
<br><br>
<img src="generate.php"/>
<form action="index.php" method="GET">
Type the verification code: <input type="text" size="6" name="secure"> <input type="submit" value="Verify">
</form>
Please help
Thanks
Clement Osei
Please i'm writing a code to generate a code foe the user to enter and submit..the process work fine but when i use imageline() function to
to generate a distort line to make the random numbers loop a bit difficult, it does not work
I mean the image line i added does not make the code work at all and even the codes not show but when i comment out the
imagelin() part then it works..please here is the code and help fix the imageline() part for me..i have generate.php page and index.php page
under generate.[php] page code here
[<?php]
session_start();
header('content-type: image/jpeg');
//we first need to stored it in a session
$text=$_SESSION['secure'];
$font_size=30; //after storing it in a session,we give a font size
$image_width=130; //we then find the image width and the image height
$image_height=40;
//we the n create our image using imagecreate function
$image=imagecreate($image_width,$image_height);
//we then give the bgcolor and the font color for the image using a function called imagecolorallocate
imagecolorallocate($image,255,255,255);
$font_color=imagecolorallocate($image,0,0,0);
//here i will use imageline function to add a little distort to the image to make it difficult to read
//i will use for loop to achiev that
for($x=0; $x<=30, $x++){
$x1=rand(1,100);
$y1=rand(1,100);
$x2=rand(1,100);
$y2=rand(1,100);
imageline($image,$x1,$y1,$x2,$y2,$font_color);
}
//we then also use a function called imagettftext function which takes 10 arqument.
imagettftext($image,$font_size,0,15,35,$font_color,'font.ttf',$text);
imagejpeg($image);
[?>]
under index.[php] code here
[<?php]
session_start();
if(!isset($_SESSION['secure'])){
$_SESSION['secure']=rand(1000,9999);
}else if($_SESSION['secure']==$_GET['secure']){
echo 'A match';
}else{
echo 'incorrect code,try again';
$_SESSION['secure']=rand(1000,9999);
}
[?>]
<br><br>
<img src="generate.php"/>
<form action="index.php" method="GET">
Type the verification code: <input type="text" size="6" name="secure"> <input type="submit" value="Verify">
</form>
Please help
Thanks
Clement Osei
Comment