input in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Anco
Forum Newbie
Posts: 2
Joined: Sat Jun 15, 2002 2:59 pm

input in php

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Anco
Forum Newbie
Posts: 2
Joined: Sat Jun 15, 2002 2:59 pm

Post 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
User avatar
phphead
Forum Newbie
Posts: 12
Joined: Tue May 28, 2002 11:03 pm
Location: California

php://stdin

Post 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";
?>
Post Reply