|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
hi....ive integrated a simple script into my site (and databases) so that if a user would like to add his/her websites link, then they can do it through a form... when the user clicks the submit button, the script trims it of extraneous space in the beginning of each field and then enters it into a table called links (in the db)... ive also made it so that the have to be logged in, in order to add a link and everythng works fine...but how would i make it so that the user is only allowed to add one link...?
the below is a snippet of the "process" action, to which the form is posted... PHP Code:
the form the db table follows is: "id", "address", "title", "description", "username", "posted" the "posted" column is either a 1, or a 0...if its a 0 then they have not posted however i think i can just get rid of that entire column if someone could enlighten me as to how to check if its a duplicate entry for the username column... thanks--
__________________
-Alexander |
|
#2
|
|||
|
|||
|
set a cookie,...or
add an extra field to your users table added_link ENUM 'Y','N'
__________________
-- Jason |
|
#3
|
|||
|
|||
|
cant i just connect to the database, check if the users username is in the table and if it is display a message telling the user that they have posted already, if not then submit the info to the database...yes yes...but how??
|
|
#4
|
|||
|
|||
|
If they are already a user, then add another field type ENUM values = 'Y','N'
then when they submit,...change that value from N to Y |
|
#5
|
|||
|
|||
|
okay, i see what you are saying, but wouldn't it just be easier to check if their username has already been input on the links table...keep in mind i'm not using the same tables here...ive got one tables thats got the users data when they registered (usernames, md5 passes, etc.) and then one that holds the links...so if there is a match between the username that the user is logged in as, and one on the links table, they shouldn't be allowed to post...my question is how do i accomplish this?
|
|
#6
|
|||
|
|||
|
ohhh I see,....
PHP Code:
![]() |
|
#7
|
|||
|
|||
|
i cant understand that...but im sure if/when i get it, it will help, thanks--
|
|
#8
|
|||
|
|||
|
heres what that is doing.
You know the user ID, either by a cookie or session. so you query your user table and the links table looking for a match in userID. Make sense? If a match exists in that query PHP Code:
Then you know what to do there. make sense? Last edited by Taelo : January 10th, 2003 at 06:51 PM. |
|
#9
|
|||
|
|||
|
Its actually quite simple fellas. Firstly add a field called userId to your links table. When a user adds a link, also store there user Id in that table.
Then to make sure that they can post again, you do the following PHP Code:
as simple as that. |
|
#10
|
|||
|
|||
|
genuis...
thanks kylie and taelo for the help |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > checking if a user has already posted |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|