tobes Posted June 18, 2006 Share Posted June 18, 2006 Hello. I'm working on a PHP project and I want it to accomplish the following tasks:1. A user copies and pastes a URL into a form and submits it.2. The PHP code validates the URL based on preset credentials and proceeds to grab the page contents of the URL.3. If the URL and the contents pass set critera, the PHP code then grabs and stores certain elements of the page into a file.I've got most of it done. I'm experienced with PHP and it should work fine. The only problem is that the URLs that are submitted into the form require preauthorization for their contents to be extracted, otherwise get_file_contents just returns the login page. Now, I do have a username and password for the site the submitted URLs are hosted on, and I can easily grab the contents of the pages manually (if I sign in and navigate to them), but I would love for it to be done automatically. Is there anyway this can be done?This is the code of my page with the form on it that users enter the URL in:[code]<form method="post" action="checkproof.php"><font face="verdana" size="3">Proof URL: <input type="text" name="proofurl" size="100"></font><br><br><input type="submit" value=" - - - Check my proof! - - - "></form>[/code]This is the beginning of the code for checkproof.php that fails:[code]<?php$proofurl = $_POST["proofurl"];$urlcontents = file_get_contents($proofurl);?>[/code]Instead of containing the content of $proofurl, $urlcontents ends up containing the main site sign in form page (several elements of which I have removed).[code]<form action="[CFN Validation Location]" method="post" name="..." id="..."><input type="hidden" name="NextPage" value="..."><input type="text" name="email" size="20"><input type="password" name="password" size="20"><input type="image" src="..." id="..." name="..." onclick="return doSubmit();"></form>[/code]Is it possible to use PHP to login to this form with my e-mail and password before calling on $urlcontents allowing access to the page contents?Thanks. Quote Link to comment Share on other sites More sharing options...
zq29 Posted June 18, 2006 Share Posted June 18, 2006 I think it's possible to do this with cURL (libcurl) and PHP. Search Google for "cURL tutorial" the official site should be at the top, or check out the curl functions in the PHP manual (I think there's some in there) Quote Link to comment Share on other sites More sharing options...
tobes Posted June 18, 2006 Author Share Posted June 18, 2006 [!--quoteo(post=385406:date=Jun 18 2006, 04:04 PM:name=SemiApocalyptic)--][div class=\'quotetop\']QUOTE(SemiApocalyptic @ Jun 18 2006, 04:04 PM) [snapback]385406[/snapback][/div][div class=\'quotemain\'][!--quotec--]I think it's possible to do this with cURL (libcurl) and PHP. Search Google for "cURL tutorial" the official site should be at the top, or check out the curl functions in the PHP manual (I think there's some in there)[/quote]Thanks much for the quick reply. I will check that out.--TobyEDIT: I just wanted to say thanks for the kick in the right direction. I found everything I needed as you suggested. Thanks again. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.