Jump to content

ID Number goes up


topflight

Recommended Posts

Hello I am creating my registreation page and if the member select a certain group that will get an ID number plus 1 (i.e Group A = 1000 if a new member were to join it their ID would be 1001 and if another member join their id would be 1002.) Each group has their own A= 1000 B= 2000 C= 3000 4= 4000. But for some reason they are not going up. Here is my code: Also you may say he has the $login = ''; Well the reason why I have that their is becuase if I don't I get an undefined login error.

 

Thanks in adnvanced.

 

<?php
include 'db.php';
$error = '';
$login = '';
session_start();
if(isset($_SESSION['LOGGEDIN'])==TRUE){
echo'You are already a member ';}

if(isset($_POST['apply']))
{
   if (!$_POST['fname']){ $error .='No First name<br>'; }
   if (!$_POST['lname']){ $error .='No Last  name<br>'; }
   if (!$_POST['email']){ $error .='No Email Address<br>'; }
   if (!$_POST['vatsimid']){ $error .='No VATSIM ID<br>'; }
   if (!$_POST['hub']){ $error .='No Hub<br>'; }
   if (!$_POST['pwd']){ $error .='No Password<br>'; }
   if (!$_POST['pwdc']){ $error .='No Password Conformation<br>'; }
   if (!$_POST['emailc']){ $error .='No Conformation Email Address<br>'; }
   if ($_POST['thours']){ if (!$_POST['thoursc']){ $error .='No comments<br>'; }}
   if ($_POST['email'] != $_POST['emailc']){ $error .='Email mismatch'; }
   if ($_POST['pwd'] != $_POST['pwdc']){ $error .='Password mismatch'; }

   if (!empty($error))
   { 
      echo $error;?> <FORM><INPUT TYPE="BUTTON" VALUE="Fix Errors" ONCLICK="history.go(-1)"></FORM> <?php 
   } 
   else 
   {
      $fpwd= $_POST['pwd'];
      $pwd = md5($fpwd);
      $fname = $_POST['fname'];
      $lname = $_POST['lname'];
      $email = $_POST['email'];
      $pilotl= mysql_query("SELECT * FROM `pilots` WHERE hub='$_POST[hub]' ORDER BY login DESC LIMIT 1") or die(mysql_error());

      $plrows = mysql_num_rows($pilotl);
      if ($plrows=="0")
      { 
         if ($_POST['hub']=="KPDX")
         { 
            $login = "1000"; 
         }
         if ($_POST['hub']=="KLAX")
         { 
            $login = "2000"; 
         }
         if ($_POST['hub']=="PANC")
         { 
            $login = "3000"; 
         }
         if ($_POST['hub']=="KSEA")
         { 
            $login = "4000"; 
         }
      } 
      else 
      {
         if(empty($error))
         {

            while($plr = mysql_fetch_array($pilotl))
            { 
               $login = $plr[login]; 
            } 
            
            $login = $login + 1;  

            $update = mysql_query("INSERT INTO `pilots` (login,pwd,fname,lname,email,hub,thours,thoursc,rating,vatsimid,date,ip,status,hm,ed,bm,active) VALUES ('$login','$pwd','$_POST[fname]','$_POST[lname]','$_POST[email]','$_POST[hub]','$_POST[thours]','$_POST[thoursc]','First Officer','$_POST[vatsimid]','$now','$ip','0','0','0',0,0)") or die(mysql_error());

            $jto = "[email protected]";
            $jsubject = "A new pilot has signed up";
            $jjmessae = "
            A new pilot ($fname $laname) with the pending ID of ($login) has submitted an Applications with Simulated Alaska. Please activate their test. ";
            $from = "[email protected]";
            $jheaders = "From: $from";

            mail($jto, $jsubject, $jmessage, $jheaders);

            $jto = "email";
            $jsubject = "A new pilot has signed up";
            $jjmessae = "
            A new pilot ($fname $laname) with the pending ID of ($login) has submitted an Applications with --------. Please activate their test. ";
            $from = "email";
            $jheaders = "From: $from";

            mail($jto, $jsubject, $jmessage, $jheaders);

            $to = "$email";
            $subject = "RE:------ Application ($fname $lname)";
            $messae = "
      Dear ($fname $lname),

      We have reccevied your application for membership with -----. You will reccevie another email within 24-48 hours regarding your entry exam. It is really importaint that you complete this exam ASAP. In order to have a membership account with Simulated Alaska you MUST pass this exam with an 80%. So in the meantime please look at the SOP's, explore the site, and study basic aircraft Maneuvers. The exam will cover(Simulated Alaska Operations, Basic Aircraft Maneuvers, and Basic Flying Skills. Once you have pass this test you will then recceive another email saying you have been accepted.




      Sincerly,
      --------
      ";

            $from = "email";
            $headers = "From: $from";
            mail($to, $subject, $message, $headers);
            echo'<b>Application Sent ------- Staff</b>';
         } 
      } 
   } 
}

?>

Link to comment
https://forums.phpfreaks.com/topic/149117-id-number-goes-up/
Share on other sites

while I am still not sold on the idea, two things i noticed:

 

            while($plr = mysql_fetch_array($pilotl))

            {

              $login = $plr[login];

            }

           

            $login = $login + 1; 

 

shouldn't the increment be inside the loop ?  right now Login is only ever incrementing once, so every new user is going to have the same ID of (GROUP)+1

 

and second, you misspelled "receive" in your confirmation email :)

Link to comment
https://forums.phpfreaks.com/topic/149117-id-number-goes-up/#findComment-783007
Share on other sites

I see now what you were attempting to do there, i guess its correct.  You loop through all of the pilot records updating $login for the current ID of each one.  after that is done, $login should have the highest ID already associated, and then after the loop you increment it by 1 to get the next ID.

 

if you sort the array descending though, the highest Login will always be first.  so if you loop through all the records you will always get the first record in the group

 

to debug it, echo out the value of $login inside the loop to see if you are getting what you expect

Link to comment
https://forums.phpfreaks.com/topic/149117-id-number-goes-up/#findComment-783022
Share on other sites

 

Notice: Undefined variable: login in /home/simasa/public_html/application.php on line 64

 

Notice: Undefined variable: login in /home/simasa/public_html/application.php on line 71

 

Notice: Undefined variable: login in /home/simasa/public_html/application.php on line 82

 

this is line 64:

            $update = mysql_query("INSERT INTO `pilots` (login,pwd,fname,lname,email,hub,thours,thoursc,rating,vatsimid,date,ip,status,hm,ed,bm,active) VALUES ('$login','$pwd','$_POST[fname]','$_POST[lname]','$_POST','$_POST[hub]','$_POST[thours]','$_POST[thoursc]','First Officer','$_POST[vatsimid]','$now','$ip','0','0','0',0,0)") or die(mysql_error());

 

Line 71

 

A new member ($fname $lname) with the pending ID of ($login) has submitted an ApplicationPlease activate their test. ";

 

Line 82

 

When registering your username should be $login $fname $lname if your username is not that your account will be deleted and you will have to re register.

 

Please help thanks.

 

Link to comment
https://forums.phpfreaks.com/topic/149117-id-number-goes-up/#findComment-783390
Share on other sites

what do u mean I am? this is my code

<?php
include 'db.php';
$error = '';
session_start();
if(isset($_SESSION['LOGGEDIN'])==TRUE){
echo'You are already a member ';}

if(isset($_POST['apply']))
{
   if (!$_POST['fname']){ $error .='No First name<br>'; }
   if (!$_POST['lname']){ $error .='No Last  name<br>'; }
   if (!$_POST['email']){ $error .='No Email Address<br>'; }
   if (!$_POST['vatsimid']){ $error .='No VATSIM ID<br>'; }
   if (!$_POST['hub']){ $error .='No Hub<br>'; }
   if (!$_POST['pwd']){ $error .='No Password<br>'; }
   if (!$_POST['pwdc']){ $error .='No Password Conformation<br>'; }
   if (!$_POST['emailc']){ $error .='No Conformation Email Address<br>'; }
   if ($_POST['thours']){ if (!$_POST['thoursc']){ $error .='No comments<br>'; }}
   if ($_POST['email'] != $_POST['emailc']){ $error .='Email mismatch'; }
   if ($_POST['pwd'] != $_POST['pwdc']){ $error .='Password mismatch'; }

   if (!empty($error))
   { 
      echo $error;?> <FORM><INPUT TYPE="BUTTON" VALUE="Fix Errors" ONCLICK="history.go(-1)"></FORM> <?php 
   } 
   else 
   {
      $fpwd= $_POST['pwd'];
      $pwd = md5($fpwd);
      $fname = $_POST['fname'];
      $lname = $_POST['lname'];
      $email = $_POST['email'];
      $pilotl= mysql_query("SELECT * FROM `pilots` WHERE hub='$_POST[hub]' ORDER BY login DESC LIMIT 1") or die(mysql_error());

      $plrows = mysql_num_rows($pilotl);
      if ($plrows=="0")
      { 
         if ($_POST['hub']=="KPDX")
         { 
            $login = "1000"; 
         }
         if ($_POST['hub']=="KLAX")
         { 
            $login = "2000"; 
         }
         if ($_POST['hub']=="PANC")
         { 
            $login = "3000"; 
         }
         if ($_POST['hub']=="KSEA")
         { 
            $login = "4000"; 
         }
      } 
      else 
      {
         if(empty($error))
         {

            while($plr = mysql_fetch_array($pilotl))
            { 
               $login = $plr[login]; 
            } 
            
            $login = $login + 1;  

            $update = mysql_query("INSERT INTO `pilots` (login,pwd,fname,lname,email,hub,thours,thoursc,rating,vatsimid,date,ip,status,hm,ed,bm,active) VALUES ('$login','$pwd','$_POST[fname]','$_POST[lname]','$_POST[email]','$_POST[hub]','$_POST[thours]','$_POST[thoursc]','First Officer','$_POST[vatsimid]','$now','$ip','0','0','0',0,0)") or die(mysql_error());

            $jto = "``````````";
            $jsubject = "A new pilot has signed up";
            $jjmessae = "
            A new pilot ($fname $laname) with the pending ID of ($login) has submitted an Applications with Simulated Alaska. Please activate their test. ";
            $from = "[email protected]";
            $jheaders = "From: $from";

            mail($jto, $jsubject, $jmessage, $jheaders);

            $jto = "email";
            $jsubject = "A new pilot has signed up";
            $jjmessae = "
            A new pilot ($fname $laname) with the pending ID of ($login) has submitted an Applications with --------. Please activate their test. ";
            $from = "email";
            $jheaders = "From: $from";

            mail($jto, $jsubject, $jmessage, $jheaders);

            $to = "$email";
            $subject = "RE:------ Application ($fname $lname)";
            $messae = "
      Dear ($fname $lname),

      We have reccevied your application for membership with -----. You will reccevie another email within 24-48 hours regarding your entry exam. It is really importaint that you complete this exam ASAP. In order to have a membership account with Simulated Alaska you MUST pass this exam with an 80%. So in the meantime please look at the SOP's, explore the site, and study basic aircraft Maneuvers. The exam will cover(Simulated Alaska Operations, Basic Aircraft Maneuvers, and Basic Flying Skills. Once you have pass this test you will then recceive another email saying you have been accepted.




      Sincerly,
      --------
      ";

            $from = "email";
            $headers = "From: $from";
            mail($to, $subject, $message, $headers);
            echo'<b>Application Sent ------- Staff</b>';
         } 
      } 
   } 
}

?>

Link to comment
https://forums.phpfreaks.com/topic/149117-id-number-goes-up/#findComment-783397
Share on other sites

In users table asign each group 1000,2000,3000 a groupname

then assign them your group value 1001,1002,1003 etc

also asign the date joined or added

 

then when a new user signs up for a group, you search based on the group selected get the last groupvalue ordered by date, or simply get the highest value in that group and add 1 then input the new user to the table

 

Link to comment
https://forums.phpfreaks.com/topic/149117-id-number-goes-up/#findComment-783841
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.