Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate a random, sequenced id based on cookie session?
    text
    copied!<p>I have a user sign up or registration form to allow guests to my site become registered members. The form consists of first name, last name, email etc, the action goes to process_reg.php on submit.</p> <p>The information is then inserted into an sql table 'ptb_registrations'. but it doesn't work yet because i am trying to randomly generate a new user id with the form from a cookie session. I'm not sure if what i'm doing is right. can people please correct me where I'm wrong or point me in the right direction. Thanks.</p> <p>here's my script for process_reg.php:</p> <pre><code>&lt;?php require_once("session.php"); require_once("functions.php"); require('_config/connection.php'); ?&gt; &lt;?php session_start(); include '_config/connection.php'; function get_user_id() { global $connection; global $email; $query = "SELECT * FROM ptb_registrations WHERE email = \"$email\" "; $user_id_set = mysql_query($query, $connection); confirm_query($user_id_set); return $user_id_set; } ?&gt; &lt;?php $user_id_set = get_user_id(); while ($user_id = mysql_fetch_array($user_id_set)) { $cookie1 = "{$user_id["id"]}"; setcookie("ptb_registrations", $cookie1, time()+3600); /* expire in 1 hour */ } ?&gt; &lt;? $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $email = $_POST['email']; $display_name = $_POST['display_name']; $date_of_birth = $_POST['date_of_birth']; $contact_number = $_POST['contact_number']; $station = $_POST['station']; $hobbies = $_POST['hobbies']; $gender = $_POST['gender']; $password = $_POST['password']; $result = mysql_query("SELECT first_name FROM ptb_registrations WHERE id=".$cookie1['user_id'].""); $result = mysql_query("SELECT last_name FROM ptb_registrations WHERE id=".$cookie1['user_id'].""); $result = mysql_query("SELECT display_name FROM ptb_registrations WHERE id=".$cookie1['user_id'].""); $result = mysql_query("SELECT email FROM ptb_registrations WHERE id=".$cookie1['user_id'].""); $result = mysql_query("SELECT contact_number FROM ptb_registrations WHERE id=".$cookie1['user_id'].""); $result = mysql_query("SELECT date_of_birth FROM ptb_registrations WHERE id=".$cookie1['user_id'].""); $result = mysql_query("SELECT hobbies FROM ptb_registrations WHERE id=".$cookie1['user_id'].""); $result = mysql_query("SELECT station FROM ptb_registrations WHERE id=".$cookie1['user_id'].""); $result = mysql_query("SELECT gender FROM ptb_registrations WHERE id=".$cookie1['user_id'].""); $result = mysql_query("SELECT password FROM ptb_registrations WHERE id=".$cookie1['user_id'].""); if(!$result) { echo "The username you entered does not exist"; } else if($email!= mysql_result($result, 0)) { echo ""; $sql=mysql_query("INSERT ptb_registrations SET first_name='$first_name' WHERE id=".$cookie1['user_id'].""); $sql=mysql_query("INSERT ptb_registrations SET last_name='$last_name' WHERE id=".$cookie1['user_id'].""); $sql=mysql_query("INSERT ptb_registrations SET display_name='$display_name' WHERE id=".$cookie1['user_id'].""); $sql=mysql_query("INSERT ptb_registrations SET email='$email' WHERE id=".$cookie1['user_id'].""); $sql=mysql_query("INSERT ptb_registrations SET contact_number='$contact_number' WHERE id=".$cookie1['user_id'].""); $sql=mysql_query("INSERT ptb_registrations SET date_of_birth='$date_of_birth' WHERE id=".$cookie1['user_id'].""); $sql=mysql_query("INSERT ptb_registrations SET hobbies='$hobbies' WHERE id=".$cookie1['user_id'].""); $sql=mysql_query("INSERT ptb_registrations SET station='$station' WHERE id=".$cookie1['user_id'].""); $sql=mysql_query("INSERT ptb_registrations SET gender='$gender' WHERE id=".$cookie1['user_id'].""); $sql=mysql_query("INSERT ptb_registrations SET password='$password' WHERE id=".$cookie1['user_id'].""); } if($sql) { echo "&lt;div class=\"infobox-profile\"&gt; &lt;strong&gt;Thank You&lt;/strong&gt; - We have received your registration details.&lt;/div&gt;"; } else { echo "&lt;div class=\"infobox-profile\"&gt; &lt;strong&gt;Oooops!&lt;/strong&gt; - Something went wrong. &lt;a href=\"../edit_contact_number.php\"&gt;Click here&lt;/a&gt; to try again.&lt;/div&gt;"; } ?&gt; &lt;? ob_flush(); ?&gt; &lt;style&gt; .infobox-profile { background-color: #e1e0f7; font-family: Arial, Helvetica, sans-serif; font-size: 14px; color: #181469; padding-top: 20px; padding-right: 10px; padding-bottom: 20px; padding-left: 70px; margin-bottom: 20px; background-image: url(../img/icons/info-icon.png); background-repeat: no-repeat; background-position: 15px center; border-top-width: 1px; border-top-style: solid; border-top-color: #8f8fdb; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-right-color: #8f8fdb; border-bottom-color: #8f8fdb; border-left-color: #8f8fdb; border-radius: 4px; width: 385px; margin-left:8px; } &lt;/style&gt; </code></pre>
 

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