Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #18047

Re: Beginner question on using PHP and POST

Path csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.php
Subject Re: Beginner question on using PHP and POST
Date Sun, 25 Aug 2019 01:31:51 +0100
Organization A noiseless patient Spider
Lines 37
Message-ID <87imqmccg8.fsf@bsb.me.uk> (permalink)
References <5d616255$0$31423$426a74cc@news.free.fr>
Mime-Version 1.0
Content-Type text/plain
Injection-Info reader02.eternal-september.org; posting-host="ea3035605b9da5182c3a9aba6bc03537"; logging-data="7905"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ftcA4eTzN9gH4EiBkjX9YHJu6sobvFZo="
Cancel-Lock sha1:nL/lU+d5UvEeW/wQIriG3eYvA7Y= sha1:MB4KJb0Oc7znZL0DosNElOQM530=
X-BSB-Auth 1.a540d3df82645e4ab4a1.20190825013151BST.87imqmccg8.fsf@bsb.me.uk
Xref csiph.com comp.lang.php:18047

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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