Jump to content

Not showing errors


topflight

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/129703-not-showing-errors/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/129703-not-showing-errors/#findComment-672559
Share on other sites

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>";


?>

 

Link to comment
https://forums.phpfreaks.com/topic/129703-not-showing-errors/#findComment-672793
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.