topflight Posted March 12, 2009 Share Posted March 12, 2009 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 More sharing options...
lonewolf217 Posted March 12, 2009 Share Posted March 12, 2009 why dont you store the value of the group in the database and increment it each time someone registers instead of having to loop through all the records every time to get the value Link to comment https://forums.phpfreaks.com/topic/149117-id-number-goes-up/#findComment-782981 Share on other sites More sharing options...
topflight Posted March 12, 2009 Author Share Posted March 12, 2009 Well becuase in the database I have it set login and the login will equal what ever the login is on the application page. Becuase some people my have a login ID of 2009 or 1006 and the database will just go 1001 1002 1003. Link to comment https://forums.phpfreaks.com/topic/149117-id-number-goes-up/#findComment-782985 Share on other sites More sharing options...
topflight Posted March 12, 2009 Author Share Posted March 12, 2009 any other suggestions or help please? Link to comment https://forums.phpfreaks.com/topic/149117-id-number-goes-up/#findComment-783003 Share on other sites More sharing options...
lonewolf217 Posted March 12, 2009 Share Posted March 12, 2009 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 More sharing options...
topflight Posted March 12, 2009 Author Share Posted March 12, 2009 login = the id number and yes the increment should be in stie the loop so they can go up one dpening on the group they selected and thanks for proof reading lol. Link to comment https://forums.phpfreaks.com/topic/149117-id-number-goes-up/#findComment-783008 Share on other sites More sharing options...
lonewolf217 Posted March 12, 2009 Share Posted March 12, 2009 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 More sharing options...
topflight Posted March 12, 2009 Author Share Posted March 12, 2009 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 More sharing options...
lonewolf217 Posted March 12, 2009 Share Posted March 12, 2009 double check that you are using the proper syntax for a php variable whenever you call $login Link to comment https://forums.phpfreaks.com/topic/149117-id-number-goes-up/#findComment-783392 Share on other sites More sharing options...
topflight Posted March 12, 2009 Author Share Posted March 12, 2009 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 More sharing options...
lonewolf217 Posted March 12, 2009 Share Posted March 12, 2009 no, your $update statement is using 'login', 'pwd', etc instead of $login, $pwd, etc Link to comment https://forums.phpfreaks.com/topic/149117-id-number-goes-up/#findComment-783399 Share on other sites More sharing options...
topflight Posted March 12, 2009 Author Share Posted March 12, 2009 yea that is the correct way to insert things into the database. Link to comment https://forums.phpfreaks.com/topic/149117-id-number-goes-up/#findComment-783402 Share on other sites More sharing options...
topflight Posted March 13, 2009 Author Share Posted March 13, 2009 any other help? Link to comment https://forums.phpfreaks.com/topic/149117-id-number-goes-up/#findComment-783522 Share on other sites More sharing options...
topflight Posted March 13, 2009 Author Share Posted March 13, 2009 please any other help would be highly appreated. Link to comment https://forums.phpfreaks.com/topic/149117-id-number-goes-up/#findComment-783806 Share on other sites More sharing options...
phpdragon Posted March 13, 2009 Share Posted March 13, 2009 a quick fix could be a seperate table for each user group, then when they select a group it will just autoinc that table and give the desired result Link to comment https://forums.phpfreaks.com/topic/149117-id-number-goes-up/#findComment-783820 Share on other sites More sharing options...
topflight Posted March 13, 2009 Author Share Posted March 13, 2009 that would however that login needs to be in that main table becuase that will be use for the login system. Link to comment https://forums.phpfreaks.com/topic/149117-id-number-goes-up/#findComment-783822 Share on other sites More sharing options...
phpdragon Posted March 13, 2009 Share Posted March 13, 2009 the user could select the user group they belong to at login or you could loop thru the tables for a match at login Link to comment https://forums.phpfreaks.com/topic/149117-id-number-goes-up/#findComment-783826 Share on other sites More sharing options...
topflight Posted March 13, 2009 Author Share Posted March 13, 2009 This was working before and now it is not that why it is so confusing Link to comment https://forums.phpfreaks.com/topic/149117-id-number-goes-up/#findComment-783827 Share on other sites More sharing options...
phpdragon Posted March 13, 2009 Share Posted March 13, 2009 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.