как отправить id страницы через форму?
как отправить id страницы вот код :
id страницы помещен в $id
$(function() {
refresh_shoutbox();
setInterval("refresh_shoutbox()", 15000);
$("#submit").click(function() {
var name = $("#name").val();
var message = $("#message").val();
var data = 'name='+ name +'&message='+ message;
$.ajax({
type: "POST",
url: "shout.php",
data: data,
success: function(html){
$("#shout").slideToggle(500, function(){
$(this).html(html).slideToggle(500);
$("#message").val("");
});
}
});
return false;
});
});
function refresh_shoutbox() {
var data = 'refresh=1';
$.ajax({
type: "POST",
url: "shout.php",
data: data,
success: function(html){
$("#shout").html(html);
}
});
}
вот файл shot.php
setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "INSERT INTO shoutbox ( date_time, name, message, page_id)
VALUES (NOW(), :name, :message, '$idr')";
/*** prepare the statement ***/
$stmt = $dbh->prepare($sql);
/*** bind the params ***/
$stmt->bindParam(':name', $name, PDO::PARAM_STR);
$stmt->bindParam(':message', $message, PDO::PARAM_STR);
/*** run the sql statement ***/
if ($stmt->execute()) {
populate_shoutbox();
}
}
}
catch(PDOException $e) {
echo $e->getMessage();
}
if($_POST['refresh']) {
populate_shoutbox();
}
function populate_shoutbox() {
global $dbh;
$sql = "select * from shoutbox WHERE page_id='$id'";
echo '
- ';
- ';
echo ''.date("d.m.Y H:i", strtotime($row['date_time'])).'';
echo ''.$row['name'].'';
echo ''.$row['message'].'';
echo ' ';
foreach ($dbh->query($sql) as $row) {
echo '
}
echo '
}
?>
Удачи в освоении JS !