...

View Full Version : PHP http url call and response



samsina
08-30-2007, 11:40 PM
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:


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.

rafiki
08-30-2007, 11:46 PM
$_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
http://www.codingforums.com/showthread.php?t=104161
click those two links

samsina
08-30-2007, 11:56 PM
$_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
http://www.codingforums.com/showthread.php?t=104161
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?

rafiki
08-31-2007, 12:06 AM
globals will no longer exist please start using the $_GET and $_POST arrays

Inigoesdr
08-31-2007, 02:39 AM
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:

<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:


// You don't need to assign them to local vars, this is just for example purposes
$userid = $_POST['userid'];
$pass = $_POST['pass'];



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum