Guys i have a problmm and i want your help.Actually i want to POST a value to php file without redirect me to this file... My form:
<form method="post" role="form" action="">
<div class="form-group">
<label>Change threshold:</label>
<input name="thr" class="form-control" id="thr" placeholder="Enter Threshold">
</div>
<button type="submit" class="btn btn-default" name="thre" >Change</button>
</form>
I tried a curl post call but it didn't work. My call:
if (isset($_POST['thre'])) {
$value=$_POST['thr'];
$json_string='{"thr":"'.$value.'"}';
$url = 'http://147.27.50.55/IDM/subsc.php';
$curl = curl_init( $url );
curl_setopt($curl,CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $json_string);
curl_setopt($curl3, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($json_string))
);
$result=curl_exec($curl);
curl_close($curl);
}
Finally i want get teh value like this:
$v=$_GET['$value'];
Where is the problem?
You need to tell the client (usually the browser) that you just want some data, not a whole new site. There is nothing the server or the PHP script can do to modify this behavior. A cURL call from your PHP script just starts another request, it will not replace the original request that your browser send to the server.
Usually this is done via javascript in the form of an XMLHttpRequest. The technique is called AJAX, all modern javascript frameworks (like jQuery) have ready made functions to handle it