2013-02-26 53 views
0

我有一个问题,其中运行两次的php页面,但它通过代理服务器连接时只运行两次。如果用户没有通过代理进行连接,此代码运行良好。php通过代理连接时运行两次

我该如何解决这个问题,让它只运行一次,无论是通过代理连接还是不连接?

此php代码在Drupal CMS页面内运行,但独立于Drupal。用户通过单击超链接进入该页面。

是我使用标题将用户重定向到另一页?

<?php 

$userId = 0; 
$userId = $_GET["userId"]; 

$userEmail = 0; 
$userEmail = $_GET["userEmail"]; 

$userName = 0; 
$userName = $_GET["userName"]; 

//connect to the database 
$con = mysql_connect("HOSTNAME","USERNAME","PASSWORD"); 
if (!$con) 
    { 
    die('Could not connect: ' . mysql_error()); 
    } 
else 
{ 
//echo "Connected."; 
//echo "<br>"; 
} 

mysql_select_db("formredirectdata", $con); 


$userId = intval($userId); 

mysql_query("INSERT INTO webforms 
(userid, formisactive, formname, formtitle, shortdesc, confirmationlink) VALUES('$userId', '1', 'Form Name', 'Form Title', 'Short Description', 'Confirmation Link') ") 
or die(mysql_error()); 

$newformnum = mysql_insert_id(); 

$recipientname = 0; 
$recipientemail = 0; 
$recipientname = "default" . $newformnum; 
$recipientemail = $userEmail; 

//send to the next script 
header('Location: addtriggernewform.php?formnum2=' . $newformnum . '&recipientemail=' . $recipientemail . '&operator=(default)&inputname=(default)&triggervalue=(default)&userName=' . $userName); 
?> 
+2

您正在将一个GET参数直接包含到SQL查询中。这是不好的,你打算开放[SQL注入](http://stackoverflow.com/questions/60174/how-to-prevent-sql-injection-in-php)。 – 2013-02-26 04:16:51

+0

你的addtriggernewform.php是否有重定向到当前页面?删除它并尝试。我只在你的脚本中看到这个可能的原因... – 2013-02-26 04:18:50

+0

Addtriggernewform在此之前重定向页面。 – mnutsch 2013-02-26 05:36:51

回答

0

我后来发现,该查询得到处理两次的原因是,我登录到使用不同用户帐户的两个不同的浏览器的网站(基于Drupal)。在其中一个浏览器中注销后,该查询不再被处理两次。这必然是一个涉及Drupal和临时互联网文件的怪癖。