Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 44
  • Last Modified:

Sql insert into question

Dear experts

I'd like to insert into my table unique user key
Every row has data but my uuk coloumn is empty

I have 4 coloumns on my table
_key, uid, pwd, uuk

My uuk coloumn is emty and i need unique user key for every user for cookie

How can i insert below formula to my database for each user?
I use php and mysql database

My table name is KullaniciBilgileri

// MAKE THE UNIQUE USER KEY
        $uuk = md5($uid . $pwd . rand());
0
Braveheartli
Asked:
Braveheartli
1 Solution
 
BraveheartliMarketingAuthor Commented:
I used this article for my page which is really good

PHP Client Registration, Login, Logout and Easy Access Control

Written by:Ray Paseur
0
 
BraveheartliMarketingAuthor Commented:
I have direct access to mysql database, can i do it with sql script or do i have to use php to do this?
0
 
Marco GasiFreelancerCommented:
I'd use php:
$uuk = md5($uid . $pwd . rand());
$query = "INSERT INTO KullaniciBilgileri (_key, uid, pwd, uuk) VALUES ('$key', '$uid', '$pwd', '$uuk')";

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Ray PaseurCommented:
Here is how I would do it...

FIrst, modify the existing code so that any new registrations automatically build the "uuk" value and store it in the database.  That will keep you from having a "regression" later.

Next, write a short and simple PHP script to do the following...

1. SELECT _key, uid, pwd FROM your database table WHERE uuk = '' /* This is an empty string */
2. Iterate over the results set.   With each row:
3. $uuk = md5($uid . $pwd . rand());
4. UPDATE your database table SET uuk = '$uuk' WHERE _key = $_key LIMIT 1

This will take on a second or two to run, and you'll only need to run it once.  Then you can use the "uuk" values as described in the article.
0
 
BraveheartliMarketingAuthor Commented:
Thank you
0
 
Julian HansenCommented:
Why not use UUID() for your unique key?
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now