Here is the summary of what i want to archive and how far i have gone using curl which seems to do my task perfectly well by triggering a file in another sever to run and update the database, but my problem now is that the database updated is not with the data or values sent from the serverA where the html form is.
<!--- html code -->
<form action="" method="post" name="cashaform" id="cashaform">
<div class="dephone">Phone <br><input type="text" name="phone" id="phone" /></div>
<div class="deemail">Email <br><input type="text" name="email" id="email" /></div>
<div class="submit"> <br><input type="submit" name="submitprime" value="Submit" id="submitprime" /></div>
</form>
// the code that processes the form and sends it to do.php on another server that updates the database with details from the form
// This is process.php in serverA
if(isset($_POST['submitprime'])){
$sphone = $_POST['phone'];
$semail = $_POST['email'];
$form_data = array(
'phone' => $sphone,
'email' => $semail
);
$str = http_build_query($form_data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://localhost/serverb/do.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $str);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
}
Now on serverB i have this file called do.php which updates the database once the process.php hits it through curl
// do.php that is on serverb
$email = 'email@example.com';
$phone = '01234567';
// update the database
$run = "INSERT INTO prime_securetable (email, phone) VALUES('$email', '$phone')";
if(mysqli_query($conn, $run) ) {
echo 'Transferred Successfully';
}else{
echo'transfer failed';
}
mysqli_close($conn);
I want the data phone and email that will be used to update the database be the one sent from the post from form in serverb, i tried it and set fixed values using email@example.com
and a fixed phone 01234567 but i want this values to be what was actually submitted from the form in serverA
and it updates the database, but i want it to be values from the form posted through curl.
Any help please.