$byFoo = 0; $foo = '';
$byBar = 0; $bar = '';
if (isset($_GET['foo']) {
$foo = $_GET['foo'];
$byFoo = 1;
}
if (isset($_GET['bar']) {
$bar = $_GET['bar'];
$byBar = 1;
}
$query = "SELECT * FROM `baz` WHERE (? = 0 OR `foo` = ?) AND (? = 0 OR `bar` = ?)";
$mysqli->bind_param('isis', $byFoo, $foo, $byBar, $bar);
<form id="order_form" method="post">
<input type="text" name="order_phone" value="1234567" />
<input type="submit" name="order_submit" value="Отправить" />
</form>
if (isset ($_POST['order_phone'])) {
$to = 'Адрес ящика получателя'
$subject = 'Заполнена контактная форма с '.$_SERVER['HTTP_REFERER'];
$subject = "=?utf-8?b?". base64_encode($subject) ."?=";
$message = "Номер телефона: ".$_POST['order_phone'];
$headers = 'Content-type: text/plain; charset="utf-8"';
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Date: ". date('D, d M Y h:i:s O') ."\r\n";
mail($to, $subject, $message, $headers);
echo ('<p style="color: green">Ваше сообщение получено, спасибо!</p>');
$_POST['order_phone'] = '';
}
$(function(){
$('input[name = "order_submit"]').click(function(){
$.ajax({
url: "test.php",
type: "POST",
data: {"phone": $('input[name = "order_phone"]').val()},
success: function(res){
alert(res);
}
});
return false;
});
});
$_POST['phone'];
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>