0

I have an issue where a php page which runs twice, but it only runs twice when connecting through a proxy server. This code runs fine if the user doesn't connect through a proxy.

How do I fix this so that it will only run once, whether connecting through a proxy or not?

This php code is running within a Drupal CMS page, but independent of Drupal. The user gets to this page by clicking on a hyperlink.

Is it that I am using header to redirect the user to another page?

<?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);
?>
mnutsch
  • 884
  • 6
  • 14
  • 2
    You're including a GET parameter directly into an SQL query. This is Bad, and you're leaving yourself open to [SQL injection](http://stackoverflow.com/questions/60174/how-to-prevent-sql-injection-in-php). – John Flatness Feb 26 '13 at 04:16
  • Is your addtriggernewform.php have a redirect to the current page? Remove it and try. I see this possible reason only in your script... – Vishnu R Feb 26 '13 at 04:18
  • Addtriggernewform redirects back the page before this one. – mnutsch Feb 26 '13 at 05:36
  • I will add myrealescape for the get lines. That's kind of a peripheral issue though. Thanks. – mnutsch Feb 26 '13 at 05:38

1 Answers1

0

I later found out that the reason the query was getting processed twice is that I was logged into the website (Drupal based) in two different browsers with different user accounts. After logging out in one of the browsers then the query no longer gets processed twice. This must be a quirk involving Drupal and temporary internet files.

mnutsch
  • 884
  • 6
  • 14