I have a website which generates each visitor a referral link (ex. http://mysite.com/?ref=12345678). The actual referral id (12345678) is a unique 8 character ID (using uniqid()
).
I then just add the ID to the end of http://example.com/?ref=....
If it does exist it shouldn't do anything.
I am guessing that I need to implement a cookie to check if the id exists, so I don't really need h开发者_运维百科elp with that. I'm just confused to how to make the script I mentioned above.
I'm trying to make the table look like this:
Unique ID
---------
3af456yT
Sa32xs21
9af456yT
8a78Fs21
1wsd4Fav
7f3Xv5Bd
Here is a great place to start: http://php.net/manual/en/book.mysql.php. The documentation will provide the information you need to connect to a MySQL database via PHP and to insert data. Specifically, you will need to use the mysql_query() function.
You can use the "UPDATE INTO" syntax to ensure that you do not create duplicate rows. Please see http://dev.mysql.com/doc/refman/5.0/en/update.html for more information.
精彩评论