Este sitio web utiliza cookies para realizar análisis y mediciones de tus visitas. [ Acepto ] [ Más información aquí ].

How to Add an IP Address to an HTML Form

If you want the forms you receive to contain the IP address belonging to the user who sends the form, follow these simple steps:

1. Add this PHP code to your webpage's header:


if (!empty($_SERVER['HTTP_CLIENT_IP'])) {


} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {


} else {




2. Under your form's opening tag (<form>), add this code:

<input type="hidden" name="ip" value="<?=$ip;?>">

In the forms you'll receive, you'll see the IP address belonging to each user under the field "ip". Users won't see nothing when filling or sending the form, since this is a hidden field.

Añadir comentario


2015-04-17 - Chris

Hi Daniel, How can I contact you? Would love to chat about some potential work we have.