Download the attachment, does anyone know how I would beable to make a form on a webpage so people can enter their name and it'll goto a new page showing the image with the name they entered? The only way you can do it right now is by entering the name after ?=
I haven't downloaded the attachment (and I can't right now -- so really if you could post anything relevant that would be great!), but.. do you just basically want to build the image using the form rather than editing the URL manually?
first off, don't forget the HTTP part of your URL.
secondly, you should understand how GET works. if you submit a form via GET, then ALL elements in the form that are NAMED objects will be reproduced in the query string. this means that if you were submitting to image.php, and you have a form with an input named "name", then the form would essentially submit to.. image.php?name=[value_you_put_in_the_field]. understand? so.. with what you were currently doing in the example you posted, you would essentially be creating: "localhost/sig/stats.php/stats/$name?name=[value]" (and since you didn't echo out '$name', it would literally show the scalar character). so, if your script works by going to 'http://localhost/sig/stats.php?name=[value]' (to display [value] in the image), then you can easily make a form that just submits to that URL.
then, you'll be submitting to 'http://localhost/sig/stats.php?name=[value]'. however, because of the way you formatted your URL (/sig/stats.php/stats/[value], rather than using a query string), you might need to get a little involved. in this case, you could POST your form and then just redirect with a header to the correct URL. something like this:
PHP Code:
<?php
//submitting?
if($_SERVER['REQUEST_METHOD'] == "POST"){
//make sure our variable is not empty and does exist
if(isset($_POST['name']) && $_POST['name'] != ""){
//redirect
header("Location: http://localhost/sig/stats.php/stats/" . urlencode($_POST['name']));
exit;
}else{
//something was empty, show the form again
$error = true;
}
}
so.. basically, when you submit that script it will submit to itself but redirect the user to the URL formatted like: http://localhost/sig/stats.php/stats/[value]
hope that made sense! I'm in sort of a rush. all untested code, but it should be fine. post any questions you might have!
Thanks, I got it to work but one last thing, is it possible to make it not redirect show when the button is pressed the image shows up and a textbox that'll give the URL to it? And heres the code (had to edit yours abit)
Code:
<?php
//submitting?
if($_SERVER['REQUEST_METHOD'] == "POST"){
//make sure our variable is not empty and does exist
if(isset($_POST['name']) && $_POST['name'] != ""){
//redirect
header("Location: http://localhost:2000/sig/stats.php/stats/". urlencode($_POST['name']. ".gif"));
exit;
}else{
//something was empty, show the form again
$error = true;
}
}
if(isset($error) || $_SERVER['REQUEST_METHOD'] != "POST"){
//show the form
?>
<form name="input" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="name" size="20" />
<input type="submit" value="go" />
</form>
<?php } ?>