PDA

View Full Version : msg for php coders!!!


SomeOne
02-19-2002, 12:41 PM
hello all!
i need a good coder 2 create 4 me a script which track and limit the use of the buttom "submit" in a form. that's mean i specify the number of limited clicks per day on "submit" per user. this is an example:

let's suppose the user "sisa" is using my form and i restricted the use of the submit buttom for this user for 3 times per day so now when he try to use it for the 4th time he should get: " sorry. u exceeded ur limit for this day..."

thnx!

slade
02-19-2002, 07:30 PM
Have two files like so:


<?php

// add.php - adds data and checks user
// connect to database and such

// where ppd is a field in the database 'acronymed' to posts per day
$query = "SELECT ppd FROM user_table WHERE username='$username'";
$result = mysql_db_query("database",$query) or die("Failed query on line ".__LINE__);
$cl = mysql_fetch_object($result);
if ($cl->ppd >= 3) {
print "Sorry, you have exceded the limit for today.";
} else {
$query = "INSERT INTO table_name VALUES ('','','','')"; // add your values and all that stuff here
mysql_db_query("database",$query) or die("failed query on line ".__LINE__);
}

mysql_close();
?>


Now have a file that lets the user add the info into the database:

<form action="add.php" method="POST">
username <input type="text" name="username">

text <textarea cols=30 rows=10 name="post"></textarea>
<input type="submit">
</form>


Hope this helps.

-Vic

SomeOne
02-20-2002, 10:43 AM
10x a lot!
i created a database but i'm receiving this error: Failed query on line 8...
???
2nd question let's suppose the user rejoined another day and tried to "submit" how can the script reset the old datas and start counting from the beginning?

10x

manual_overide
05-20-2002, 04:54 PM
why not just create a cookie based on the date?

well, i guess that would work if you only wanted 1 per day or something...

sweede
05-28-2002, 06:58 PM
replace the sections,

die("failed query on line ".__LINE__);

with

die("failed query: ". $query . "
");


and that will show you your SQL query if there is an error there.