Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Nov 2004
    Thanked 0 Times in 0 Posts

    how to enter a value using php ?

    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

  • #2
    Super Moderator
    Join Date
    May 2002
    Perth Australia
    Thanked 101 Times in 99 Posts
    PHP Code:
    function getstdin ($str){
    $fp fopen("php://stdin","r");
    $line fgets($fp,255);

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

    "\nPassword's accepted";
    "Your passwords do not match";
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts