...

View Full Version : how to enter a value using php ?



graziano
12-28-2006, 09:25 AM
I need to ask a value to visitor with a prompt for example

echo "enter a value to continue..."

after this echo the script should prompt and wait for a value followed by enter.

If the visitor enter the value then I execute the next php code .

This php script should work from linux command line
It should work like this


Please enter a password ... (prompt)


The user enter a password , click enter , and the script continue the execution.


With perl it's possible with following way

print "What password ? ";
$pass = <STDIN>;

is there some way to do that with php ?
Thank you

firepages
12-28-2006, 01:27 PM
<?php
function getstdin ($str){
echo $str;
$fp = fopen("php://stdin","r");
$line = fgets($fp,255);
return trim($line);
}

$pass1 = getstdin("Please enter a password:");
$pass2 = getstdin("Please confirm password:");

if($pass2==$pass1){
echo "\nPassword's accepted";
}else{
echo "Your passwords do not match";
}
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum