Preventing multiple SQL entrys that are same as previous?
Posted: Tue Oct 30, 2007 2:37 pm
My website is a basic form, where you post info, and it shows it on another page.. Like a messaging system, but no signing in or anything along those lines. There's five columns total in my table- post, name, email, message, IP, and date.
There's two things I wish to achieve;
-Prevent a `message` entry that's the same as the previous.
-Prevent a user's `IP` from posting more than one entry per 30 seconds (using the date column somehow?).
For the first part, my code looks something like:
I can't do that though, as someone else had pointed out to me, $message is a string, but $last_post is not. How do I go about making $last_post a string instead?
Oh, and I can't set the column `message` as UNIQUE or anything, because it's far too large.
And the second part, I really don't know where to begin. Any ideas? :\
There's two things I wish to achieve;
-Prevent a `message` entry that's the same as the previous.
-Prevent a user's `IP` from posting more than one entry per 30 seconds (using the date column somehow?).
For the first part, my code looks something like:
Code: Select all
$last_post = mysql_query("SELECT MAX(post), message FROM `users");// "post" is a auto_increment column that numbers the posts
$message = htmlspecialchars($messagea); //variable messagea previously defined in code as a filtered $_POST
IF ( $message == $last_post ) {
die(' Duplicate entrys! ');
}
ELSE {
execute code, ect
}Oh, and I can't set the column `message` as UNIQUE or anything, because it's far too large.
And the second part, I really don't know where to begin. Any ideas? :\