I'm developing an ASP.net website in which I have to allow users to log into someone else's PHP website. On my ASP.net homepage and interior pages I have two text boxes - one for Username and another for Password, and a button for submitting the data. What's the code for posting the login information to the external PHP site from my ASP.net site?

(I thought this would be a common task but haven't found any sample solutions when I Googled)

Thanks
(newbie)

Recommended Answers

All 5 Replies

Does the other site have an API you need to interact with or are you hoping to send the data to the login page of the second website? If the other site doesn't have the required functionality built into it you may not be able to log in except at their log in page.

Does the other site have an API you need to interact with or are you hoping to send the data to the login page of the second website? If the other site doesn't have the required functionality built into it you may not be able to log in except at their log in page.

The administrator of the PHP site has given me the code for interacting with his site (i.e. field names I should use on my site) so I can post the data directly to the PHP site. Do I need other information too?

Here's what he gave me (which I've de-identified!)

<script language='JavaScript'>
            <!--
            if (self.location.href != top.location.href) {
                top.location.href = self.location.href;
            }
            // -->
        </script>
<form action='https://www.XXX.com.au/auth.php' method='post'>
     <table>
          <tr>
               <td><font size=2 face=verdana color='#ffffff'><b>Username:</b></font></td>
               <td><input type='text' size='13' name='login'></td>
          </tr>
          <tr>
               <td><font size=2 face=verdana color='#ffffff'><b>Password:</b></font></td>
               <td><input type='password' size='13' name='password'></td>
          </tr>
          <tr>
               <td colspan='2' style='text-align:center'><br />
                    <input type='Submit' value='Login'></td>
          </tr>
          <tr>
               <td colspan='2' style='text-align:center'><br />
                    <a href='https://www.XXXX.com.au/forgotpass.php'>Forgot your password?</a></td>
          </tr>
     </table>
</form>

Thanks
cobberas

Ok, that helps. You can simply mimic that form code on your page and when the user logs in they will be redirected to the second. In my first post I was really asking if you wanted to send the user to the second site or some how use the users credentials on your site.

Ok, that helps. You can simply mimic that form code on your page and when the user logs in they will be redirected to the second. In my first post I was really asking if you wanted to send the user to the second site or some how use the users credentials on your site.

Yes, I want to send the user to the second site (and have them log in to that second site from my site) but I can't use the line

<form action='https://www.XXX.com.au/auth.php' method='post'>

in my code because mine is an ASP.net page and so it already has a <form> tag:

<form name="aspnetForm" method="post" action="/Membership/ERIS_logon/ERIS_logon.aspx?" id="aspnetForm">

In which case, how do I post the data entered by the user?

Yes, I want to send the user to the second site (and have them log in to that second site from my site) but I can't use the line

<form action='https://www.XXX.com.au/auth.php' method='post'>

in my code because mine is an ASP.net page and so it already has a <form> tag:

<form name="aspnetForm" method="post" action="/Membership/ERIS_logon/ERIS_logon.aspx?" id="aspnetForm">

In which case, how do I post the data entered by the user?

I'm not sure if this is relevant but perhaps I should add that my ASP.net page is part of a content management system. I've added the code for the text fields and submit button to the content control and they display correctly on the page, but I don't know how to code the submit button so it posts data to the external PHP site.

Any ideas would be enormously appreciated!

Thanks
(newbie)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.