Avatar of mropenmind
mropenmind
 asked on

PHP - Post login data and then get the source of the page that requires login.

Hi there.

There is a login form on the page index.php

				<form method="POST" action="login.php">
					<table border="0" cellpadding="4" cellspacing="1" class="w12">
						<tr>
							<td>Login:</td>
							<td>
								<input type="text" name="username" class="b12">
							</td>
						</tr>
						<tr>
							<td>Password:</td>
							<td>
								<input type="password" name="password" class="b12">
							</td>
						</tr>
						<tr>
							<td colspan="2" align="right">
								<input type="submit" value="Login">
							</td>
						</tr>
					</table>
				</form>

Open in new window


When the form on index.php is posted, it generates session id on the same page and then passes login data to login.php.

How do I programmatically post the login data via php, and then get the source code of the page called sourceineed.php ?

Thank you.
PHPPythonPerl

Avatar of undefined
Last Comment
mropenmind

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
James Williams

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
mropenmind

ASKER
it returns nothing.
James Williams

The above is inclusive of a few more parameters the you requested but may need..

You may need the point 'cookies.txt' to that file.

To get the source of the page you need you could wrap that page in a shell.


<?php
$file=file_get_contents("THE above page url");

DO SOME THING WITH $file..

Selvol
mropenmind

ASKER
I'm trying to login to: http://gm.heroesofnewerth.com using PHP.
Your help has saved me hundreds of hours of internet surfing.
fblack61
James Williams

Oh snaps. Apologies


Remove these lines.


$return = str_replace('<body ', '<!-- ', $return);
$return = str_replace('bgcolor="#FAf7EF"  >', ' -->', $return);
$return = str_replace('</TBODY>', '<!-- ', $return);

As they were hiding the <html>

Elvol
mropenmind

ASKER
removed the lines at response is still nothing
mropenmind

ASKER
If you post anything to login.php without session id, it just doesn't let you to login.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
James Williams

Any way I can login?  To test this page?

mail85224@gmail.com

Selvol
mropenmind

ASKER
I've sent you an email
James Williams

no
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Dave Baldwin

You know that even if you succeed, you will only get the HTML generated by the PHP page and not the PHP source.
mropenmind

ASKER
I know.... I don't need a PHP source.