[英]php session between two pages
我的目標是當用戶點擊播放location_id
時打開一個新會話(有一個帶有用戶會話的登錄系統),然后他被重定向到下一頁,他將從數據庫中選擇數據。 當print_r
會話時,我得到location_id
空會話(用戶會話很好!)
用戶在這里選擇一個點
$location_id = $_GET['location_id'];
echo $location_id;
var i ; var confirmed = 0;
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,
icon : locations[i][4] === '1' ? red_icon : purple_icon,
html: "<div id='window_loc'>\n" +
"<form method='POST' action='question.php'>\n" +
"<table class=\"map1\">\n" +
"<tr>\n" +
"<td><input type='hidden' id='manual_description'/>"+locations[i][3]+"</td></tr>\n" +
"<tr>\n" +
"<td><textarea disabled id='question' placeholder='Question'>"+locations[i][5]+"</textarea></td></tr>\n" +
"<tr>\n" +
"<td><input type='hidden' name='location_id' id='location_id' value="+locations[i][0]+" /></td></tr>\n" +
"<td><input id='button1' name='play' type='submit' value='play'/> </td></tr>\n" +
"</table>\n" +
"</form>\n" +
"</div>"
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow = new google.maps.InfoWindow();
confirmed = locations[i][4] === '1' ? 'checked' : 0;
$("#confirmed").prop(confirmed,locations[i][4]);
$("#location_id").val(locations[i][0]);
$("#description").val(locations[i][3]);
$("#form").show();
infowindow.setContent(marker.html);
infowindow.open(map, marker);
}
})(marker, i));
}
我已將此添加到用戶被重定向但會話為空的頁面(有一個 session_start 並且它可以工作 - print_r
顯示用戶 ID)
$location_id = $_GET['location_id'];
echo $location_id;
也許這可以幫助:
$location_id = $_GET['location_id'];
(GET 方法),但是在您的 JS 中,您使用<form method='POST'
(POST 方法)創建了一個表單。 因為這個, $location_id
不是總是空的嗎? 也許這就是為什么你的$_SESSION
沒有任何變化。
你在哪里更新你的$_SESSION
數據? (它沒有顯示在代碼中)。 您可以將其更改為: $_POST['location_id']
_ $_POST['location_id']
試嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.