1

Background: I have a form with multiple submit buttons (about 25) all of which will send to an external .php file. This will track which is clicked, add to MYSQl database and then use the header to go to the corresponding html page based on the value of the submit. It works great when it works...

Problem: This only works 2 - 3 times, then I will see a page with text that says "No data received" "ERR_EMPTY_RESPONSE" (Chrome - same issue on all broswers). It seems that the header doesn't work as it leaves me at the .php itself.

Example: I click a submit button on the main page, I am taken to the corresponding page, I go back to main page, click another button, it works again, go back to main page, it then gives me an error page. Then error page from then on out.

Code:

submit button example:

<button type="submit" value="ALT_2_3_W1" name="altnum" id="ALT_2_3_W1-submit" class="">Explore</button>

php:

$database = 'DATABASE NAME';

$server = mysql_pconnect($db_host, $db_username, $db_password);

$connection = mysql_select_db($db_name, $server);
if (!$connection) {
  die('Not connected : ' . mysql_error());
}
    //VARIABLES FROM FORM FIELDS
    $alternativenum = $_POST['altnum'];
    header('Location:map_'.$alternativenum.'.html');

    $myquery = "UPDATE altDashboardTracking SET altCount = altCount + 1 WHERE altName = '".$alternativenum."' LIMIT 1";
    $query = mysql_query($myquery);

?>

Could this be a database connection issue?

I could use hard links but I need to be able to track which of the submit buttons are being clicked the most for a study.

Other information: The MYSQL database is being used to output to some D3.js charts so I would prefer to use this method and have it work.

Thanks for all of your responses.

Eric

Eric.18
  • 463
  • 4
  • 20
  • 1
    25 submit buttons? Usability nightmare – nomistic Jul 01 '15 at 13:47
  • So do you have a better way? I need all buttons to submit to fork without have a single selection then submit. – Eric.18 Jul 01 '15 at 13:50
  • Ok, sounds like you have different forms, which also might work better, and easier to track the problem down. Note, you are wide open form sql injection, and are using deprecated code (`mysql_` functions). Considering this and also, since you are sending large amounts of data, for security and speed you could use prepared statements (either `PDO` or `mysqli_`) – nomistic Jul 01 '15 at 13:56
  • For reference, see the warning message on the function you are using: mysql_pconnect: http://php.net/manual/en/function.mysql-pconnect.php – nomistic Jul 01 '15 at 13:58
  • If you can, you should [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). They are no longer maintained and are [officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) [statements](http://php.net/manual/en/pdo.prepared-statements.php) instead, and consider using PDO, [it's really not hard](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard Jul 01 '15 at 13:59
  • Thanks. Even using mysqli_ instead I am still having the same issue of the error message. – Eric.18 Jul 01 '15 at 14:15
  • so no one has any ideas? – Eric.18 Jul 01 '15 at 20:08

0 Answers0