0

I'm working on this small booking system for a band, I originally built it for my A-Level project and now I'm going through and finalizing the code before I actually put the website online. Before I put it online, there's two things I'd like to rectify, my account registration page and my Support Ticket system.

With the account registration system

After a users details have been validated, a query is executed to insert their details into the database. Simple stuff. For the system however, I use a userID for basically everything, and currently I have to execute another query to select the auto_incremented userID that was just generated, to get this, before logging in. For example:

$SQL = "INSERT INTO ebs_users (`email`, `name`, `password`,`postcode`, `telnum`, ) VALUES ('$email', $name', '$password','$postcode','$telnum');";
  $SQL = Query($SQL);

$SQL = "SELECT userID FROM ebs_users WHERE email = '$email';";
  $_SESSION['userID'] = mysqli_fetch_assoc($SQL);

With my support tickets

I have a table of Tickets and a table of Messages, Tickets represent the whole enquiry as a whole, and a message is, well, one specific message in that enquiry. Currently I create a somewhat unique ID by exploding the message, hashing the first word, inserting it with the ticket and then using this little snippet to fetch the recently created ID, there most be an easier way to simply fetching an ID?

I've read that there's the function mysqli_insert_id, which will return the last insert ID. Would this function return the exact ID of the row I've just created?

Thanks in advance for your help.

Mophead64
  • 43
  • 4

0 Answers0