Send and recieve text from a server

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
mbarbier
Forum Newbie
Posts: 2
Joined: Sat Aug 05, 2006 11:22 am

Send and recieve text from a server

Post by mbarbier »

Hi,

I'm a somewhat experienced PHP programmer, but have just been faced with a task I can't figure out. I'm supposed to send a single line of text to a server at a given URL, and get its reply for use in my page.

To help you understand better, this is the background:

I am a TA at a university and I'm attempting to implement a system for posting student grades. The university's rules on Internet grade posting require that you have students authenticate using a university-assigned username and password, and then you can pull grades for them based on their username.

You have to create an HTML form whose action attribute is the login server and with a hidden input field of the page you want the login page to return the user to. They log in, and a special cookie is given to the browser. Then they are sent back to the return address.

So you're back to your original page, except now you have this cookie. It contains a hash code. Then you have to send this hash code to another server, and it will reply with the student's username.

That's the part I can't figure out how to do. Just send a line of text to a URL, and I guess wait for a reply. Then put the reply into a variable and use it. How do I do that?

I am posting here because I am on a tight schedule and I have already tried asking officials at the University but they take weeks to get back to you, which I do not have.

I'd appreciate any help on this problem. Thanks!
-Mike
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

fsockopen(), file_get_contents() or curl are the options fairly often. In what format does this second interaction expect the data in?
mbarbier
Forum Newbie
Posts: 2
Joined: Sat Aug 05, 2006 11:22 am

Post by mbarbier »

I figured it out - I used the PHP socket functions.

Thanks though,
-Mike
Post Reply