FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


cURL problems..





Diablosblizz
I am having some issues with cURL. It's not really cURL, but it's checking if the gotten message from the curl request is correct to a form. Here is what I have:

Code:
<?php
//include("config.php");

switch($_GET['page']) {
   default:
   ?>
   <form action="?page=submit" method="post">
   Username: <input type="text" name="username">
   Password: <input type="text" name="password">
   <input type="submit" value="Login!">
   </form>
   <?php
   break;
   
   case 'submit':
   // define the variables
   $username = $_POST['username'];
   $password = $_POST['password'];
      $database = "http://can't-give-out-ip/users/$username";
      $curl_handle=curl_init();
      curl_setopt($curl_handle,CURLOPT_URL,"$database/pass.txt");
      curl_exec($curl_handle);
      curl_close($curl_handle);
      if(curl_exec == $password) {
         echo "<BR>Hello!";
      } else {
         echo "<BR>Too bad!";
      }
   }
?>


As you can see, on the submit case, it gets the username and password from the post and then creates the URL with $database. Then it sets it to the full URL, and basically prints it out. I want to then take that print (echo) and check if it matches EXACTLY to the form. As you can see, I have the if(curl_exec) but that does not work. I have also tried putting a variable over the cURL, but that didn't work.

If anybody has any idea that would be great!

Kind regards.
Dougie1
Does this not work???

$result = curl_exec($curl_handle);
curl_close ($curl_handle);
if(
$result == $password) {
echo
"<BR>Hello!"; }


I recommend using file() for things like this anyway because cURL is really meant for getting hold of other sites, not your own site.

Have you tried debugging it yourself, like add in capturing it in a variable like above and then echoing it to see if it works?
Diablosblizz
No, that does not work. I did this:

Code:
      $database = "http://cant-give-out-ip/users/$username";
      $curl_handle=curl_init();
      curl_setopt($curl_handle,CURLOPT_URL,"$database/pass.txt");
      $result = curl_exec($curl_handle);
      curl_close($curl_handle);
      if($result == $password) {
         echo "<BR>Hello!";
      } else {
         echo "<BR>Too bad!";
      }


I should have been more clear, I am using this to get information from my local web host (hosted on my computer). I apologize if you have gotten confused.
Related topics
Facing Many Problems
New forum area (computer problems)
Linux or Windows on your computer?!
Problems With Index Page
FTP problems --> Use Filezilla and/or active mode
problems
Curl and OpenSSL
Problems with provider
Host Problems
Laptop Bootup Problems...
Gmail Problems
Audio problems
Admin : Does the PHP installed has CURL ?
Problems adding CURL package
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.