topflight Posted October 23, 2008 Share Posted October 23, 2008 Hello all I have a script (basic registration script) that is not displaying the errors. Instead it just says Application sent to database. <?php include 'db.php'; $ip = $_SERVER['REMOTE_ADDR']; $now = date("m.d.y"); ?> <?php $fname = $_POST['fname']; $lname = $_POST['lname']; $email = $_POST['email']; $emailc = $_POST['emailc']; $hub = $_POST['hub']; $vatsimid = $_POST['vatsimid']; $pwd = $_POST['pwd']; $pwdc = $_POST['pwdc']; $thours = $_POST['thours']; $thoursc = $_POST['thoursc']; if ($_POST[apply]=="1"){ if (!$fname){ $error .='No first name<br>'; } if (!$lname){ $error .='No last name<br>'; } if (!$email){ $error .='No email<br>'; } if (!$emailc){ $error .='No confirmed email<br>'; } if (!$hub){ $error .='No hub<br>'; } if (!$vatsimid){ $error .='No VATSIM id<br>'; } if (!$pwd){ $error .='No password<br>'; } if (!$pwdc){ $error .='No confirm password<br>'; } if (!$thours){ $error .='No hours<br>'; } if ($thoursc){ if (!$thoursc){ $error .='No comments<br>'; }} if ($email != $email){ $error .='Email mismatch'; } if ($pwd != $pwdc){ $error .='Password mismatch'; } if ($error){ echo $error; } else { $plist = mysql_query("SELECT * FROM `pilots` WHERE hub='$_POST[hub]' ORDER BY login DESC LIMIT 1") or die(mysql_error()); $plrows = mysql_num_rows($plist); if ($plrows=="0"){ if ($_POST[hub]=="KSEA"){ $login = "1000"; } if ($_POST[hub]=="PANC"){ $login = "2000"; } if ($_POST[hub]=="KPDX"){ $login = "3000"; } if ($_POST[hub]=="KLAX"){ $login = "4000"; }} else { while($plr = mysql_fetch_array($plist)){ $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) VALUES ('$login','$_POST[pwd]','$_POST[fname]','$_POST[lname]','$_POST[email]','$_POST[hub]','$_POST[thours]','$_POST[thoursc]','First Officer','$_POST[vatsimid]','$now','$ip','0','0','0',0)") or die(mysql_error()); echo "<b><center>APPLICATION SENT TO SYSTEM</center></b>"; ?> What could be the problem thanks in advanced. Quote Link to comment Share on other sites More sharing options...
johnsmith153 Posted October 23, 2008 Share Posted October 23, 2008 Are you sure that $_POST[apply] is set to 1? (from the form you post to this script) Quote Link to comment Share on other sites More sharing options...
philipolson Posted October 23, 2008 Share Posted October 23, 2008 If you fix your whitespace it'd be much MUCH easier to debug. An example of nice whitespace: <?php $foo = 'bar'; if ($foo === 'bar') { echo "Hello"; } else { if ($stuff) { echo "Hello"; } } See how easy that is to debug? Trust me, it's well well well worth it. Quote Link to comment Share on other sites More sharing options...
topflight Posted October 23, 2008 Author Share Posted October 23, 2008 Are you sure that $_POST[apply] is set to 1? (from the form you post to this script) Yes that is here see this: Join.php <table align="center" cellpadding="1"> <form action=appcheck.php method=post> <tr> <td width="63"><b>First Name</b></td> <td width="144"><input type="text" name="fname" value="<?php echo $_POST['fname'];?>" /></td> </tr> <tr> <td><b>Last Name</b></td> <td><input type="text" name="lname" value="<?php echo $_POST['lanme'];?>" /></td> </tr> <td><b>Email</b></td> <td><input type="text"name="email" value="<?php echo $_POST['email'];?>"/></td> </tr> <td><b>Confirmation Email</b></td> <td><input type="text"name="emailc"/></td> </tr> <td><b>VATSIM ID</b></td> <td><input type="text"name="vatsimid" value="<? echo $_POST['vatsimid'];?>"/></td> </tr> <td><b>Hub</b></td> <td> <select name="hub"> <option value= selected>SELECT ONE</option> <option value=KSEA>Seattle</option> <option value=PANC>Anchorage</option> <option value=KPDX>Portland</option> <option value=KLAX>Los Angeles</option> </select> </td> </tr> <tr><td colspan=2><hr height=1></td></tr> <td><b>Transferable Hours </b></td> <td><input type="text"name="thours" value="<? echo $_POST['thours'];?>"/></td> </tr> <td><b>Transfer Hours</b></td> <td><textarea cols="40" rows="5" name="thoursc">Link To Transferable Hours.</textarea></td> </tr> <tr><td colspan=2><hr height=1></td></tr> <td><b>Password</b></td> <td><input type="password"name="pwd"/></td> </tr> <td><b>Confirm Password</b></td> <td><input type="password"name="pwdc"/></td> </tr> <td><input name="submit" type="submit" name="apply" value="Join Simasa!"/></td> <td><input name="reset" type="reset"/></td> </form> appcheck.php <?php include 'db.php'; $ip = $_SERVER['REMOTE_ADDR']; $now = date("m.d.y"); ?> <?php $ip = $_SERVER['REMOTE_ADDR']; $fname = $_POST['fname']; $lname = $_POST['lname']; $email = $_POST['email']; $emailc = $_POST['emailc']; $hub = $_POST['hub']; $vatsimid = $_POST['vatsimid']; $pwd = $_POST['pwd']; $pwdc = $_POST['pwdc']; $thours = $_POST['thours']; $thoursc = $_POST['thoursc']; if ($_POST[apply]=="1"){ if (!$fname){ $error .='No first name<br>'; } if (!$lname){ $error .='No last name<br>'; } if (!$email){ $error .='No email<br>'; } if (!$emailc){ $error .='No confirmed email<br>'; } if (!$hub){ $error .='No hub<br>'; } if (!$vatsimid){ $error .='No VATSIM id <br>'; } if (!$pwd){ $error .='No password<br>'; } if (!$pwdc){ $error .='No confirm password<br>'; } if (!$thours){ $error .='No hours<br>'; } if ($thoursc){ if (!$thoursc){ $error .='No comments<br>'; }} if ($email != $email){ $error .='Email mismatch'; } if ($pwd != $pwdc){ $error .='Password mismatch'; } if ($error){ echo $error; } else { $plist = mysql_query("SELECT * FROM `pilots` WHERE hub='$_POST[hub]' ORDER BY login DESC LIMIT 1") or die(mysql_error()); $plrows = mysql_num_rows($plist); if ($plrows=="0"){ if ($_POST[hub]=="KSEA"){ $login = "1000"; } if ($_POST[hub]=="PANC"){ $login = "2000"; } if ($_POST[hub]=="KPDX"){ $login = "3000"; } if ($_POST[hub]=="KLAX"){ $login = "4000"; }} else { while($plr = mysql_fetch_array($plist)){ $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) VALUES ('$login','$_POST[pwd]','$_POST[fname]','$_POST[lname]','$_POST[email]','$_POST[hub]','$_POST[thours]','$_POST[thoursc]','First Officer','$_POST[vatsimid]','$now','$ip','0','0','0',0)") or die(mysql_error()); echo "<b><center>APPLICATION SENT TO SYSTEM</center></b><p>"; ?> Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted October 23, 2008 Share Posted October 23, 2008 change $_POST[apply] to $_POST['apply'] Quote Link to comment Share on other sites More sharing options...
topflight Posted October 23, 2008 Author Share Posted October 23, 2008 still just saying sent to database Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted October 23, 2008 Share Posted October 23, 2008 try this if (empty($fname)){ $error .='No first name<br>'; } Quote Link to comment Share on other sites More sharing options...
topflight Posted October 23, 2008 Author Share Posted October 23, 2008 still saying app sent to the system and it will insert into the database to. Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted October 23, 2008 Share Posted October 23, 2008 try echoing out $_POST['apply'] and see what you get Quote Link to comment Share on other sites More sharing options...
topflight Posted October 23, 2008 Author Share Posted October 23, 2008 I reccevie an T String error. Quote Link to comment Share on other sites More sharing options...
topflight Posted October 23, 2008 Author Share Posted October 23, 2008 I did do that right? or should be <?php if((isset$_POST['apply']){ //some code here ?> Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted October 23, 2008 Share Posted October 23, 2008 Change if((isset$_POST['apply']) to if(isset($_POST['apply'])) Quote Link to comment Share on other sites More sharing options...
topflight Posted October 23, 2008 Author Share Posted October 23, 2008 still just insert into the database wierd. Quote Link to comment Share on other sites More sharing options...
topflight Posted October 24, 2008 Author Share Posted October 24, 2008 does anybody else know what the problem is? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.