Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #18047
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: Beginner question on using PHP and POST |
| Date | 2019-08-25 01:31 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <87imqmccg8.fsf@bsb.me.uk> (permalink) |
| References | <5d616255$0$31423$426a74cc@news.free.fr> |
Dan Wissme <wissme@free.fr> writes:
> I write an HTML page foods.html containing a form like :
>
> <form method="post" action="process.php">
> <p><input type="text" name="food" id="food"></p>
> <input type="submit" value="OK">
> </form>
>
>
> The purpose is to get from user the name of the food and open a web
> page already existing about that food. The user may ask for 'meat' for
> example. I will then open the web page meat.html
>
> So I wrote a file "process.php" like that one :
>
> <?php
> $food=htmlspecialchars($_GET["food"]);
> <--------- what then ?
> ?>
You don't need htmlspecialchars, but you should sanitise the input. For
example, you could check that $_POST['food'] (or $_REQUEST['food'])
contains nothing but lowercase letters.
> I tried echo, readfile, etc but got nothing...
You could use PHP's header function like this:
header("Location: $food.html");
exit();
This cases the HTTP response to include a redirection header. A
confirming browser will then request the HTML document in question.
--
Ben.
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Beginner question on using PHP and POST Dan Wissme <wissme@free.fr> - 2019-08-24 18:14 +0200
Re: Beginner question on using PHP and POST "R.Wieser" <address@not.available> - 2019-08-24 18:47 +0200
Re: Beginner question on using PHP and POST "R.Wieser" <address@not.available> - 2019-08-24 18:53 +0200
Re: Beginner question on using PHP and POST Martin Leese <please@see.Web.for.e-mail.INVALID> - 2019-08-24 12:35 -0600
Re: Beginner question on using PHP and POST Martin Leese <please@see.Web.for.e-mail.INVALID> - 2019-08-24 13:04 -0600
Re: Beginner question on using PHP and POST Jeroen Belleman <jeroen@nospam.please> - 2019-08-24 23:59 +0200
Re: Beginner question on using PHP and POST Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-08-25 01:31 +0100
Re: Beginner question on using PHP and POST Arno Welzel <usenet@arnowelzel.de> - 2019-08-26 09:27 +0200
csiph-web