0

I have problem with the cURL look at my code



www.example1.com/index.php

$Email = $_POST['Email'];
$Password = $_POST['Password'];

$sql = $dbh->prepare('SELECT * FROM users WHERE Email = ? AND Password = ?');
$sql->execute(array($Email,$Password));

if($sql->rowCount() == 1) {
    $data = array('Found'=> 'Great');
    $string = http_build_query($data);

    $ch = curl_init("http://www.example2.com/index.php");
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_exec($ch);
    curl_close($ch);
}else{
    $data = array('Found'=> 'Sorry');
    $string = http_build_query($data);

    $ch = curl_init("http://www.example2.com/index.php");
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_exec($ch);
    curl_close($ch);  
}

www.example2.com/index.php

$data = array('Email'=>'[email protected]', 'Password'=>'Password');
$string = http_build_query($data);

$ch = curl_init("http://www.example1.com/index.php");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
curl_close($ch);


if(isset($_POST['Found'])) {
   $Found = $_POST['Found'];
   echo $Found;
}

it didn't echo anything in www.example2.com so what can i do so i can echo the Found variable

sorry for my bad English i hope you understand me and thank you :)

14
  • You're not binding the variables to the prepared statement. Have a look at the docs for mysqli_stmt::bind_param Commented Nov 9, 2017 at 14:19
  • can you give me a code example Commented Nov 9, 2017 at 14:20
  • None of your curl_exec are assigning the returntransfer data to a variable (nor echoing it). ? Commented Nov 9, 2017 at 14:40
  • 1
    Also I dont understand your examples, because if you run example1, curl is going to call example2, and thats going to call example1, and loop forever ? Commented Nov 9, 2017 at 14:42
  • 1
    @frozenjakalope Judging by his code, it looks like he is using PDO, which wont understand bind_param. He is doing it right in execute. Commented Nov 9, 2017 at 14:44

1 Answer 1

1

Try to save the output of the curl to a variable like this:

$Found = curl_exec($ch);

Sign up to request clarification or add additional context in comments.

2 Comments

what can i do after i save the output?
Try to see if it's what you want by printing it like this echo "$Found"; or this var_dump($Found);

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.