Help required with form submission
Posted: Wed Mar 02, 2011 6:18 pm
Can any body help, I am new to PHP and am learing php via various books. I would like to make a user defined png image to create a graph. The problem is that the code I am using does not work. I have simplified the code just to create a black box. If I can get this to work then I can produce my graph. This is the code, can some one let me know where I have gone wrong?
if (!$_POST) {
echo "
<html>
<head>
<title>Iamge Creation Block</title>
</head>
<body>
<h1>Create an Image</h1>
<form action="<?php echo $_SERVER["PHP_SELF"];?>" method="POST">
<P><strong>Image Size:</strong><br/>
W: <input type="text" name="w" size="5" maxlength="3" />
H: <input type="text" name="H" size="5" maxlength="3" /><p>
<P><input type="submit" name="submit" value="Create Image" /></P>
</form>
</body>
</html>";
} else {
//create the canvas
$myimage = imagecreate($_POST["W"], $_POST["H"]);
//set up some colors
$black = ImageColorAllocate ($myimage,0,0,0);
//output the image to the browser
header ("Content-type: image/png");
ImagePng($myimage);
//clean up after your self
ImageDestroy($myimage);
}
?>
if (!$_POST) {
echo "
<html>
<head>
<title>Iamge Creation Block</title>
</head>
<body>
<h1>Create an Image</h1>
<form action="<?php echo $_SERVER["PHP_SELF"];?>" method="POST">
<P><strong>Image Size:</strong><br/>
W: <input type="text" name="w" size="5" maxlength="3" />
H: <input type="text" name="H" size="5" maxlength="3" /><p>
<P><input type="submit" name="submit" value="Create Image" /></P>
</form>
</body>
</html>";
} else {
//create the canvas
$myimage = imagecreate($_POST["W"], $_POST["H"]);
//set up some colors
$black = ImageColorAllocate ($myimage,0,0,0);
//output the image to the browser
header ("Content-type: image/png");
ImagePng($myimage);
//clean up after your self
ImageDestroy($myimage);
}
?>