Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP http url call and response

    hello guys....
    at work i have to develop this user authentication. they have provided me with a link that make REST method calls to user/pass and if correct then dumps true to the page or some false message otherwise.

    for example:

    http://www.example.com/auth?user=admin&pass=password

    my problem is that i don't know how to make html reqeust with php and google didn't help since i am not searching with correct key words.

    here is what i would do in java:

    Code:
    HttpClient client = new HttpClient(); 
    PostMethod method = new PostMethod("http://www.example.com/auth?userid=admin&pwd=password"); 
    method.setParameter("userid",username); //username, password supposedly defined.
    method.setParameter("pwd",password); 
    try { 
    client.executeMethod(method); 
    } catch (Exception e) { 
    e.printStackTrace(); 
    } 
    String result = method.getResponseBodyAsString(); 
    create = ((result != null) && 
    (result.indexOf("True") > -1)); 
    }
    '

    any help is appreciated.
    thanks.

  • #2
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    $_GET['user'];
    $_GET['pass'];
    though i would make your form post to the php script.
    $_POST['user'];
    $_POST['pass'];
    www.google.com/search?q=basic+php+tutorials
    Resources to Learn PHP
    click those two links

  • #3
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question

    Quote Originally Posted by rafiki View Post
    $_GET['user'];
    $_GET['pass'];
    though i would make your form post to the php script.
    $_POST['user'];
    $_POST['pass'];
    www.google.com/search?q=basic+php+tutorials
    Resources to Learn PHP
    click those two links
    i am sorry... not sure if you understood my question or you are being funny... i think i really know what global variables are... that was not what i was asking. any body else?

  • #4
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    globals will no longer exist please start using the $_GET and $_POST arrays

  • #5
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    Quote Originally Posted by samsina View Post
    i am sorry... not sure if you understood my question or you are being funny... i think i really know what global variables are... that was not what i was asking. any body else?
    To add to rafiki's post, you would make a form:
    Code:
    <form action="page.php" method="post">
    UserID: <input type="text" name="userid" /><br />
    Password: <input type="password" name="pass" /><br />
    <input type="submit" value="Login" />
    </form>
    And you would access the variables in your PHP script like so:
    PHP Code:
    // You don't need to assign them to local vars, this is just for example purposes
    $userid $_POST['userid'];
    $pass $_POST['pass']; 


  •  

    Posting Permissions

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