Hey guys am creating a tool in which user is allowded to write the name and and when the user click the submit button he/she gets the image by his/her name..
<html>
<body>
<form action="images.php" method="post">
Enter image Name :<input type="text" name="imagename">
<br></br>
<input type="submit" name="sumbit">
<br></br>
</form>
</body>
</html>
header("Content-Type: image/png");
$name = $_POST['imagename'];
if(isset($_POST['submit']) === true)
{
$im = @imagecreate(800, 600)
}
else echo "no image created";
$background_color = imagecolorallocate($im, 0xFF, 0xCC, 0xDD);
$text_color = imagecolorallocate($im, 133, 14, 91);
imagestring($im, 5, 300, 300, "$name", $text_color);
imagepng($im);
imagedestroy($im);
When i run this code i get an error ..i need to generate the image only when user clicks submit button ..but i cant link my submit button to the php script ..Hope you guys can help me out ..Thanks
You miss ;
in $im = @imagecreate(800, 600);
. Move your image generation code into if
condition.
if($_POST['imagename'] != ''){
header("Content-Type: image/png");
$name = $_POST['imagename'];
$im = imagecreate(800, 600);
$background_color = imagecolorallocate($im, 0xFF, 0xCC, 0xDD);
$text_color = imagecolorallocate($im, 133, 14, 91);
imagestring($im, 5, 300, 300, "$name", $text_color);
imagepng($im);
imagedestroy($im);
}
else echo "no image created";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.