Note that there are some explanatory texts on larger screens.

plurals
  1. POAppoint a unique registration code
    primarykey
    data
    text
    <p>I have a registration form on my site for users to sign up to become members. </p> <p>When they register their details are sent to the mysql database, and their email, name etc is all put in. they also get a unique registration code which is generated by random md5 on submit and this code is entered into the database as well as it being emailed to them. </p> <p>The problem i am getting is each time a new user signs up a new code is generated but it re-writes over the previous code for all the other users in the database. What i want is for each users code to stay unique and for it not to re-write over the others each time a new user signs up, so I'm thinking that i need to edit my code to say </p> <pre><code>UPDATE `ptb_registrations` SET `registration_code` = '%s' WHERE email = (whatever unique email the user enters) </code></pre> <p>any one got any ideas? thanks</p> <pre><code>&lt;?php /** * ShuttleCMS - A basic CMS coded in PHP. * random code - Used for allowing a user to reset password * * @author Dan &lt;dan@danbriant.com&gt; * @version 0.0.1 * @package ShuttleCMS */ define('IN_SCRIPT', true); // Start a session session_start(); /* * Generates registration code and puts it on database */ //Generate a RANDOM MD5 Hash for a code $random_code=md5(uniqid(rand())); //Take the first 8 digits and use them as the code we intend to email the user $emailcode=substr($random_code, 0, 8); //Encrypt $emailcode in MD5 format for the database $registrationcode=($emailcode); // Make a safe query $query = sprintf("UPDATE `ptb_registrations` SET `registration_code` = '%s' ", mysql_real_escape_string($registrationcode)); mysql_query($query)or die('Could not update members: ' . mysql_error()); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload