Jump to content

Multiple "posts"


korsohill

Recommended Posts

Can I make a webpage log into one of two differet areas with radio buttons?For example, I'm making a page that will easily log me in to check my grades at school, however, they have two different addresses, one that works only at school and one that works anywhere else. Can I use radio buttons to choose between "School" and "Home"?

Link to comment
Share on other sites

It's the same thing as with any other form element. You give all radio buttons the same name and different values, like you normally set up radio buttons, and when it gets submitted you'll find the value they chose in $_POST under the name that you used for the radio group.

Link to comment
Share on other sites

It depends how the other site logs in. If you're just submitting a username and password then you can set the action of the form to the other site, whichever page they have that processes the login form, and make sure that your input names are the same as what they expect. Basically, you only have to send them the same information that they get from their own login form. PHP cannot log you in to another site, if you use PHP to send a login request to a remote server, it's going to start a session for the PHP server, not your browser. If you need to dynamically change the action on a form before you submit it then you would use Javascript for that.

Link to comment
Share on other sites

You'll want to get started going through the Javascript tutorials. In broad terms, you'll need a click event on each radio button, so the attribute to use would be onclick for each button. The click event handler needs to be a function that just sets the action of the form with the value on the radio button. In order to do that, you need to give the form an ID. Inside the function, you would use document.getElementById to get the form object. I think that form objects have an action property, so you would just set the action property of the form object to the value of the radio button (assuming that you're storing the various URLs as the values of the radio buttons). If you need to replace the entire form when you click the radio button, like if each site has a different set of login fields, it's a lot more complicated.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...