tags:

views:

180

answers:

3

How would I go about creating a system in which a user must click a link to validate something.

Let us say that on my website, each user has their own folders that are not shared. I want their to be an option for each user on their account page in which they can create a trust with another user to access each others folders. Perhaps by typing in the name of the user in which they want to create a trust with.

So in this case, user Jim types into his create trust input box "Tom", and so a trust needs to be established. I figure, A) There will need to be something that stores Jim's request, B. then assigns it as unverified, C. and finally then sends the vaerification link to Tom. Tom then recieves a message somehow? (not sure yet), perhaps with something to check and see if there are any verification links for Tom? and then Tom clicks the verification link sent to verify that he wants to also establish a trust with Jim. once Tom clicks it, A. tells whatever it is that stored Jim's request that Tom accepted, B. assigns validation as verified C. notifies Jim that Tom's request has been accepted or declined.,

HOWEVER there also needs to be a way to remove the validation storage (whatever it will be) if 24 hours runs up, or Tom declines Jim's request.

Can anyone please help me? :)

+1  A: 

Sounds like a good job for a database. When user A requests a share, it is entered in the database as pending. When user B is notified, he can click a link who's script will check the database for the original request, verify that it is within 24 hours, and if so, the database record us updated as accepted or declined. If 24 hours is up, the record is updated as expired.

KOGI
+1  A: 

If you're using a database, this is simple. Just generate some sort of unique ID for each request, and store the request (with status "awaiting response" or similar) in the database, then send an email to Tom with a link to one of your php pages with the unique ID of the request in the querystring.

This way, you can save update the "time accepted" field for the request to whenever Tom clicked the link in his email, and change the status to "accepted".

It is trivial to logically determine if 24 hours have passed, and you can deny access to the trusted share after this time period.

John Rasch
+1  A: 

Hi.
You can define a table wich has the attributes:
-Unique ID
-ID1 (Of Person 1)
-ID2 (Of Person 2)
-Validated State (TRUE OR FALSE)
-Validation Hash MD5(Name(ID1)+RANDOM(100,99999),Name(ID2))
-Date and Time of requested relationship
-Other information pertinent to the system that needs this function...

Then you proceed like you said.
1)On 12/5/2009 at 5:25pm Tom (ID=15) asks Mark(ID=21) to join his network, then your script add the data to the table as follows:
-Unique ID: Assigned automatically by autoincrement
-ID1: 15
-ID2: 21
-Validated: False
-Validation Hash MD5: MD5("Tom".42574."Mark")=bedbcfc6e679be69ff3587f15213c83f
-Date and Time: 12/5/2009 at 5:25pm
-Other information pertinent to the system that needs this function...

Be sure that, before setting the data into database, check for duplicates.
After that, erase all fields wich Date And Time is older than 24 hours =D

2)If no duplicates, Send mail to Mark with a link back to your page, including md5 hash as a Get attribute of the url. Lets sat the page name is validate.php?h=bedbcfc6e679be69ff3587f15213c83f

3)Your script validate.php recieves a request with the get parameter h=bedbcfc6e679be69ff3587f15213c83f
Proceed to chek de db.
If hash exists, and date and time is not older than 24hours, set Validated to true, and send a mail to Tom's email with the info of his new friend.
If hash does not exists, inform it to Mark throught the validation page results.

Ok. Thats all. Hope its usefull to you in some way.

Gero
You are my hero. XD!
=) Also think about, as said in the others responses, you can also avoid deleting the expired fields, and mark them as expired, so you can have a sort of statistics =)
Gero