Hello, I am making a user registration that will automatically make the username the next number after the last username, and I would like after they register for the php to recieve pilot_id from the last row of the table and show it to the user, this is my current code to display successful:
//confirm
echo "Pirep Sent!";
Thanks
Darko
EDIT: Okay I have it working now most of the way, this is my code and I still have one problem with it:
<?
//initilize PHP
if($_POST['submit']) //If submit is hit
{
//then connect as user
//change user and password to your mySQL name and password
mysql_connect("db5.awardspace.com","darko886_fsacars","");
//select which database you want to edit
mysql_select_db("darko886_fsacars");
//convert all the posts to variables:
$name = $_POST['name'];
$city = $_POST['city'];
$country = $_POST['country'];
$email = $_POST['email'];
$Table = "pilots";
$pilot_num = "pilot_num";
//selects last pilot ID number
$sql=mysql_query("SELECT * FROM $Table WHERE ID=$pilot_num ORDER BY IDColum DESC LIMIT 1");
//Insert the values into the correct database with the right fields
$result=MYSQL_QUERY("INSERT INTO pilots (pilot_id,pilot_num,name,city,country,email,admission_date,status)".
"VALUES ('$sql+1', 'INV$sql', '$name', '$city', '$country', '$email', '', 'Active')");
//confirm
$new=mysql_query("SELECT * FROM $Table WHERE ID=$pilot_num ORDER BY IDColum DESC LIMIT 1");
print "Congratulations, you are now a InvictaJet pilot! Your pilot id is $new";
}
?>
When I try to create a pilot, there are 2 rows it especially needs to look out for, these are the pilot_id and pilot_num.... pilot_id is a 3 digit number for example 518 and pilot_num are the letters INV plus those 3 digits. Now what I tried to do with the $sql and $new is with $sql make it find the last pilot_id and add 1 to that, for example 518 to 519, and then also with $sql make make it create a row with INV before the 3 digit $sql... and then with $new at the end I tried making it to re-query the mysql and pick up the last row (supposed to be the one it just created) and post the pilot_num... Now the problem is it made the pilot_id 1 and the pilot_num INV, and on the print "Congratiulations bla bla bla it did not put anything for $new it just left it blank..... If anyone could help me with this it would be great...