Hello,
I have a script called confirmation.php - When a user clicks the confirmation link in their email the script runs like this:
<?php
include ('config.php');
//set variable
$passkey=$_GET['passkey'];
//Retrieve data from temp table
$sql="SELECT * FROM tempuser WHERE passkey='$passkey'";
$result=mysql_query($sql);
////////////////////////////////////
/
//Get last id /
$sql2="SELECT MAX(id) FROM user"; /
$result2=mysql_query($sql2); /
/
////////////////////////////////////
//did not successfully queried
if(!$result)
{
echo 'Query unnsuccessfull';
}
//How many rows have key
$count=mysql_num_rows($result);
//If passkey is not in db dont retrieve data
if (!$count==1)
{
echo 'Passkey not found';
}
//Fetch it
$rows=mysql_fetch_array($result);
$pass=$rows['password'];
$email=$rows['email'];
$lname=$rows['lname'];
$name=$rows['name'];
$rank=$rows['rank'];
$rankpic=$rows['rankpic'];
$country=$rows['country'];
$countrypic=$rows['countrypic'];
$vatsimid=$rows['vatsimid'];
$ivaoid=$rows['ivaoid'];
$city=$rows['city'];
$fsversion=$rows['fsversion'];
//Insert into perm table
$sql = "INSERT INTO user (password, email, lname, name, rank, rankpic, country, countrypic, vatsimid, ivaoid, city, fsversion)
VALUES ('$pass', '$email', '$lname', '$name', '$rank', '$rankpic', '$country', '$countrypic', '$vatsimid', '$ivaoid',' $city', '$fsversion')";
$result = mysql_query($sql);
//Remove from temp table
$sql2 = "DELETE FROM tempuser WHERE passkey='$passkey'";
$result3 = mysql_query($sql2);
if ($result&&$result3)
{
echo 'Successfull!';
}
?>
The part that i have selected with /'s is the problem, i need to get the heighest value ID from the ID column then from the same row fetch the pilotid Which is in formatt DEY3302 then increment it by 1, so, DEY3303 then insert that into the permtable.
Any ideas?
Cheers