-1

我有一个脚本,在我的客户页面上

<a href='hueimx.php?action=edit&uid={$result['uid']}'>click to edit</a>

{$result['uid']} 

这是我从数据库中获取的客户 ID。

现在我想在我的 javascript 页面上接收“uid”值。这是我的代码:

function insert() {
// Optional: Show a waiting message in the layer with ID login_response
document.getElementById('huemix_message').innerHTML = "<img src='images/saver.gif' />"
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
var system_name= encodeURI(document.getElementById('system_name').value);
var system_logo = encodeURI(document.getElementById('system_logo').value);
var system_number = encodeURI(document.getElementById('system_number').value);
var system_tel = encodeURI(document.getElementById('system_tel').value);
if($("#system_pics").is(':checked')){
      var system_pics = 1;
   } else {
      var system_pics = 0;
   }
if($("#system_bread").is(':checked')){
      var system_bread = 1;
   } else {
      var system_bread = 0;
   }

// Set te random number to add to URL request
nocache = Math.random();
// Pass the login variables like URL variable
http.open('get', 'huemixpanel_insert.php?system_name='+system_name+'&system_logo='+system_logo+'&system_number='+system_number+'&system_tel='+system_tel+'&system_pics='+system_pics+'&system_bread='+system_bread+'&uid='+uid+'&nocache = '+nocache);
http.onreadystatechange = insertReply;
http.send(null);
}

在这个页面中,我从设置页面收到所有值并将其转发到 php 页面以将它们插入数据库。一切正常,但我不知道如何接收“uid”值并如您所见发送。

4

1 回答 1

0

好吧,如果您的唯一目标是将数据从一页发送到另一页。然后,您可以通过在 URL 中附加数据来轻松完成此操作。而在另一页上,只需抓取数据并处理您的操作。

您的脚本非常适合发送数据。在另一页“ *huemixpanel_insert.php* ”上,请考虑添加这行代码:

<?php
if(!empty($_GET['uid']))
{
    $uid = strip_tags($_GET['uid']); // check for security hole
    //Your rest of the  ***huemixpanel_insert.php*** code goes down here...  
} else {
    //You can die the rest of the page if uid is not received. (Optional) don't use else if you don't want to take any action. 
}
?> 
于 2013-03-15T22:24:04.327 回答