Re: using WinINET to authenticate in php website
- From: "Volodymyr Shcherbyna" <v_scherbina@xxxxxxxxxxxxxxx>
- Date: Wed, 15 Apr 2009 11:25:46 +0200
I will give you the general advises which should help you to perform this
job yourself.
1. First, use WireShark sniffer to see response from server, so that you
would know if you are doing something wrong.
2. Second, after you sent request to server, make sure WireShark shows that
the response is proper. If it is not proper, navigate to server using IE or
FireFox, and look in WireShark how request is formed by these browsers.
After this send request using your application and see how it differs from
request which are sent by IE or FF. If it is different, adjust your code.
3. After you sent request you have to read response from server using
HttpQueryInfo and InternetReadFile
HTH,
--
Volodymyr M. Shcherbyna, blog: http://www.shcherbyna.com/
(This posting is provided "AS IS" with no warranties, and confers no
rights)
"dominolog" <dominiktomczak@xxxxxxxxx> wrote in message
news:9e9f79bd-1207-4ae7-bd44-17637c0b3965@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello
I have a PHP web server that exposes a login.php page where user can
enter username and password in text boxes. Those text boxes have
following code:
<form id="loginForm" name="loginForm" method="post"
action="login.php"><p>
<label for="name">Username:</label>
<br />
<input type="text" name="username" size="22" tabindex="3"
id="name" class="logintext" />
<br />
<label for="password">Password:</label>
<br />
<input name="password" type="password" class="logintext"
id="password" tabindex="4" size="22" />
<br />
<a href="recoverpass.php" title="Forgot!">Forget your password?
No sweat. We'll send it.</a><br />
<input type="hidden" name="action_login" value="Log In" />
<input type="image" src="images/login.gif" tabindex="5"
class="loginbutton" />
</p>
</form>
How can I use WinINET to execute the login.php giving the credentials
so that my win32 application will log into this PHP server?
I use InternetOpen, InternetConnect, HttpOpenRequest, HttpSendRequest
but then I do not havy any idea what to do next. My code looks like
following (no error checking):
m_hInternet = ::InternetOpen( _T("Client"),
INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
DWORD_PTR dwContext = (DWORD_PTR)0;
m_hInternetConnect = ::InternetConnect( m_hInternet.get(), _T
("mreplay.com"),
INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0,
dwContext);
const HINTERNET hOpenRequest = ::HttpOpenRequest
( m_hInternetConnect.get(), _T("POST"),
_T("login.php"),
NULL,
NULL,
NULL,
INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_RELOAD,
(DWORD_PTR)0 );
TCHAR params[] = _T("username=xxx&password=yyy");
result = HttpSendRequest( hOpenRequest, NULL, 0, params, sizeof
(params) );
What to do next?
Thanks
Dominik
.
- Follow-Ups:
- Re: using WinINET to authenticate in php website
- From: dominolog
- Re: using WinINET to authenticate in php website
- References:
- using WinINET to authenticate in php website
- From: dominolog
- using WinINET to authenticate in php website
- Prev by Date: Re: setting socket option by setsockopt() have no effect
- Next by Date: Re: Force IP packets on the wire.
- Previous by thread: using WinINET to authenticate in php website
- Next by thread: Re: using WinINET to authenticate in php website
- Index(es):