I have PHP form processing data to sql table i have two input field
- i need a hidden field that hidden field should track client IP address and when form is submitted i need the client address also save in table
PHP form processing
<?php
$db_username = "sanoj";
$db_password = "123456";
try {
#connection
$conn = new PDO('mysql:host=localhost;dbname=localtest', $db_username, $db_password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$data = $conn->prepare('INSERT INTO test (first, last) VALUES (:first, :last)');
$first = filter_input(INPUT_POST, 'first', FILTER_SANITIZE_STRING);
$last = filter_input(INPUT_POST, 'last', FILTER_SANITIZE_STRING);
$data->execute(array(':first' => $first, ':last' => $last,));
#exception handiling
} catch (PDOException $e) {
echo $e->getMessage();
}
?>
can some one help me i found example and its hard to understand these code given in What is the most accurate way to retrieve a user's correct IP address in PHP? since new to php
thanks in advance