So i was working on a php web application. Here is the form(trackit.php) i am working on.
<?php
function curlPOST($fields) {
$url = 'http://example.com/mailit4.php';
//url-ify the data for the POST^M
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
return $result;
}
$lid = $_GET["lid"];
$list_id = $_GET["list_id"];
$phone=$_GET["phone"];
/*
$filename = 'leadids.txt';
$contents = file($filename);
$myfile = fopen("leadids.txt", "a") or die("Unable to open file!");
*/
$fields = array('lid' => $lid, 'list_id' => $list_id, 'phone'=> $phone);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Client Appreciation Weekend 2016</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<table width="986" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><img src="images/example" alt="example.com" width="600" height="133" style="margin-left:180px;" border="0" usemap="#Map" /></td>
</tr>
</table>
<table width="986" border="0" align="center" cellpadding="0" cellspacing="0">
<form action="<?curlPOST($fields)?>" method="post" >
<tr>
<td>
<label>Phonenumber:</label>
</td>
<input type="hidden" name="lid" id="lid" size="40" value= "<?=$lid?>">
<input type="hidden" name="list_id" id="list_id" size="40" value= "<?=$list_id?>">
<td >
<input type="text" name="phonenumber" id="phonenumber" size="40" value= "<?=$phone?>"> <br>
</td>
</tr>
<tr align="center">
<td>
<input type="submit" name="btnSubmit" value="Submit Data">
</td>
</tr>
</form>
</table>
</body>
</html>
?>
I am posting these three values to mailit4.php using curl post. When i click submit it calls that function and run mailit4.php script which is on the other server. Everything is working fine but when i am trying to redirect my page to thanks.html which is on this server(where trackit.php is). Its doing nothing. Can anyone please how i can redirect to thanks.html
here is my code for mailit4.php
<?php
$db = mysqli_connect('localhost', 'example', 'example', 'example');
$lid = $_POST['lid'];
$list_id = $_POST['list_id'];
$phone=$_POST['phone'];
$sql = "SELECT list_id FROM exampleWHERE lead_id=$lid";
$result = mysqli_query($db,$sql);
$value = mysqli_fetch_row($result);
if ($value[0] != $list_id){
$body = "Leadid " . $lid . " : " . $list_id . "
";
$subject = "Zombie Drip:" . $lid . " : " . $list_id;
mail("example@gmail.com", $subject, $body);
}
$query = mysqli_query($db, "UPDATE example SET list_id=$list_id,called_since_last_reset='N',phone_number=$phone WHERE lead_id=$lid");
if($query){
header('Location: http://example.com/thanks.html/');
exit;
}
else{
$body = "Leadid " . $lid . " : " . $list_id . "
";
$subject = "It could not update the example due to some reasons " .$query ;
mail("example@gmail.com", $subject, $body);
}
?>
Thanks