Can Someone Tell Me how to make a auto posting form .
I need theat form for automatic pots ip on sql db,
Please Help Thx.

Dani AI

Generated

Thread summary and concise best practices.

was trying to submit the visitor IP via a client-side form; correctly pointed out you can (and should) record the IP on the server instead of posting it from the browser. For a reliable, maintainable solution, log the address on each request using a modern DB API and follow these practical recommendations.

Use a modern API and prepared statements (avoid the old mysql_* calls). Persist IPs in a form that supports IPv6 (for example a binary 16-byte column) and convert addresses reliably with server-side helpers (PHP has inet_pton; MySQL has INET6_ATON). Let the database set the timestamp with a TIMESTAMP/DATETIME default rather than formatting dates in PHP. Capture optional context such as user agent or referer, but validate and normalize every value before insertion. See the PDO manual for prepared statements (PDO manual) and PHP address conversion (inet_pton); MySQL address helpers are documented as well ().

Security, robustness and privacy notes: prepared statements prevent injection (see OWASP guidance on SQL injection), restrict DB user privileges, handle proxy headers (do not trust X-Forwarded-For without validation), check for failed conversions, and throttle or dedupe logs to avoid spam. Remember that IPs can be personal data under laws like GDPR—define retention and notice policies as needed (GDPR overview). If inserts fail, confirm DB permissions, enabled PHP DB extensions, and that conversion helpers return valid values.

Recommended Answers

All 6 Replies

I think we'd need more information on just what it is you're trying to do, and clarification on your second sentence, in order to help.

Can Someone Tell Me how to make a auto posting form .
I need theat form for automatic pots ip on sql db,
Please Help Thx.

Error file

<?php 
$ip = getenv("REMOTE_ADDR") ;
print_r($_POST['ip']);
?>
<form name="form1" method="post" action="ip ban.php">
<input type="submit" name="ip" id="ip" value="<?php echo $ip ;?>">
</form>

Post File

<?php 
include "sec/db.php";
if (isset($_POST['ip'])) {$ip = $_POST['ip']; if ($ip == ''){unset($ip);}}
?>
<?php
if (
isset($ip)
)
{
$date = date("Y-m-d-H-m-s");
$result = mysql_query ("INSERT INTO ip (ip,date) VALUES ('$ip','$date')");}
?>
<?php
$url="index.php";
$timeout_minutes = 0;
$timeout_seconds = 1;
sleep($timeout_seconds + $timeout_minutes * 60);
exit;
?>

And i need theat te $ip to be posted automaticli (sry Bad englesh)

Do you even need a form? It looks like you're just wanting log the ip address of the visitor.

Is there any reason not to just go ahead and run the query to insert it?

If that's all you're trying to do, it could be done in just a couple of lines of code, and the date could be formatted right in the sql query rather than in PHP.

Let me know and if that's it I can help.

Yes this is what I wanted to do

I think this is what you want:

mysql_query ("INSERT INTO ip (ip,date) VALUES ('".$_SERVER["REMOTE_ADDR"]."',NOW()") or die(mysql_error());

Search Google on "mysql now()" for further information if you what to modify the date format used.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.