Page 1 of 1
input in php
Posted: Sat Jun 15, 2002 2:59 pm
by Anco
Hi, I´ve a question about input in php.
Is HTML forms the only way to catch input from a users keyboard or is there other/better ways?
In case there are other phpfunctions just post the names of them and I can look them up. Im looking for functions similar to cin or scanf in C/C++.
thanks in advance
Posted: Sat Jun 15, 2002 5:02 pm
by twigletmac
Because PHP is server-side you can't use it for logging keystrokes. In order to get input from a user data has to be sent either through the URL in a query string or via an HTML form.
If you explain a bit more what you are trying to achieve we'll probably be able to help more.
Mac
Posted: Sun Jun 16, 2002 4:40 am
by Anco
well, what Im trying to do is a commandlike driven prompt and I don't want those forms waste my design, but that might be a HTML problem, (not sure if you can do forms invisible, not hidden though) so I can explore that in other channels, but thanks for the reply.
/blanco
php://stdin
Posted: Sun Jun 16, 2002 9:49 am
by phphead
PHP has stdin and stdout streams that you can use.
Code: Select all
<?
$in = fopen("php://stdin", "r");
echo "What is your age: ";
//-------------| 255 is the length of the input string. users can also hit enter.
$input = fgets ($in, $255);
$age = ($input + 10)
echo "in 10 years you'll be $age";
?>