Frage

I am trying to find out and track what browser and if a proxy is being used when I receive form submissions. I have the following code below:

<?php

$browser = $_SERVER['HTTP_USER_AGENT'];
$ip_address = $_SERVER['REMOTE_ADDR'];
if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) {
    $ip_address = array_pop(explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']));
}

?>

For example I tried the below but it does not work. It is not submitting any data with my form.

What am I doing wrong?

echo ('<input type="hidden" name="browser" value="' . $browser . '" />' );
War es hilfreich?

Lösung

echo '<input type="hidden" name="browser" value="'.$browser.'">'

Andere Tipps

What am I doing wrong?

  • You are not referencing the variable with a $
  • You need to correctly escape the variable value from the string

Try printf

printf('<input type="hidden" name="browser" value="%s">', $browser);

You are combining echo and print (which both do the same) into one call. For another thing, you haven't closed the input element HTML (notice the final greater than sign I've added):

echo ('<input type="hidden" name="browser" value="' . $browser . '" />' );

Try this way

echo ("<input type='hidden' name='browser' value='".$browser."'");
echo ('<input type="hidden" name="browser" value="'.$browser.'">');

Try with this -> value="'.$browser.'" something like that

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top