androwowor
11-26-2010, 10:51 AM
Hello,
I'm a poor with PHP for Knowledge.
How to deny exists IP Address from which it already logged in Database if someone wants to type and submit a form for a twice or more.
I mean the user only have a chance to submit the form for one time only, by detecting from their IP Address if it has been submitted before.
Is it possible to restrict some user to validating the form again if that user already submitted that form?
I do so much thankful in advanced for your help.
The form code:
<form name="registration_form" method="post" action="register.php">
Email: <input type="text" size"475" name="email">
<input id="ip" name="ip" value='<?php echo $_SERVER["REMOTE_ADDR"]; ?>' type='hidden'>
<input id="date" name="date" value='<?php echo $_SERVER["REMOTE_ADDR"]; ?>' type='hidden'>
<input type="submit" value="Submit">
</form>
The register.php code:
<?php
$con = mysql_connect("localhost","dbuser","dbpass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("dbname", $con);
$sql="INSERT INTO dbtable (ip, email)
VALUES
('$_POST[ip]','$_POST[email]')";
if (!mysql_query($sql,$con))
{
}
echo 'You are now Part of Us.';
mysql_close($con)
?>
<?php
$subject = 'You are now joined with Us';
$headers = "From: Company.Inc noreply@company.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$message .= '<tr>Thank you 1</tr>';
$message .= '<tr>Thank you 2</tr>';
$message .= '<tr>Thank you 3</tr>';
$message .= "</body></html>";
mail($_POST[email], $subject, $message, $headers);
?>
I'm a poor with PHP for Knowledge.
How to deny exists IP Address from which it already logged in Database if someone wants to type and submit a form for a twice or more.
I mean the user only have a chance to submit the form for one time only, by detecting from their IP Address if it has been submitted before.
Is it possible to restrict some user to validating the form again if that user already submitted that form?
I do so much thankful in advanced for your help.
The form code:
<form name="registration_form" method="post" action="register.php">
Email: <input type="text" size"475" name="email">
<input id="ip" name="ip" value='<?php echo $_SERVER["REMOTE_ADDR"]; ?>' type='hidden'>
<input id="date" name="date" value='<?php echo $_SERVER["REMOTE_ADDR"]; ?>' type='hidden'>
<input type="submit" value="Submit">
</form>
The register.php code:
<?php
$con = mysql_connect("localhost","dbuser","dbpass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("dbname", $con);
$sql="INSERT INTO dbtable (ip, email)
VALUES
('$_POST[ip]','$_POST[email]')";
if (!mysql_query($sql,$con))
{
}
echo 'You are now Part of Us.';
mysql_close($con)
?>
<?php
$subject = 'You are now joined with Us';
$headers = "From: Company.Inc noreply@company.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$message .= '<tr>Thank you 1</tr>';
$message .= '<tr>Thank you 2</tr>';
$message .= '<tr>Thank you 3</tr>';
$message .= "</body></html>";
mail($_POST[email], $subject, $message, $headers);
?>