dudejma Posted August 5, 2011 Share Posted August 5, 2011 How do I get this to put in the pilotID? header("Location: logbook.php?id=" . $pilotid); Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/243959-header/ Share on other sites More sharing options...
Maq Posted August 5, 2011 Share Posted August 5, 2011 Looks right to me, what's the problem? Quote Link to comment https://forums.phpfreaks.com/topic/243959-header/#findComment-1252640 Share on other sites More sharing options...
dudejma Posted August 5, 2011 Author Share Posted August 5, 2011 I have $pilotid = $row['pilotID'] up top but it doesn't carry over the variable, it just goes to logbook.php. Quote Link to comment https://forums.phpfreaks.com/topic/243959-header/#findComment-1252644 Share on other sites More sharing options...
AyKay47 Posted August 5, 2011 Share Posted August 5, 2011 you probably have $pilotid in a conditional statement or loop, without seeing your code its impossible to tell Quote Link to comment https://forums.phpfreaks.com/topic/243959-header/#findComment-1252646 Share on other sites More sharing options...
Maq Posted August 5, 2011 Share Posted August 5, 2011 I have $pilotid = $row['pilotID'] up top but it doesn't carry over the variable, it just goes to logbook.php. Post the relevant code. Quote Link to comment https://forums.phpfreaks.com/topic/243959-header/#findComment-1252647 Share on other sites More sharing options...
dudejma Posted August 5, 2011 Author Share Posted August 5, 2011 if(!isset($adminid) || !isset($adminpass) || !isset($position)) { header("Location: index.php"); } $pilotid = $row['pilotID']; $id = $_GET['id']; That's what's before and after it. Quote Link to comment https://forums.phpfreaks.com/topic/243959-header/#findComment-1252650 Share on other sites More sharing options...
Maq Posted August 5, 2011 Share Posted August 5, 2011 I don't see a header call to logbook.php. Quote Link to comment https://forums.phpfreaks.com/topic/243959-header/#findComment-1252666 Share on other sites More sharing options...
AyKay47 Posted August 5, 2011 Share Posted August 5, 2011 if(!isset($adminid) || !isset($adminpass) || !isset($position)) { header("Location: index.php"); } $pilotid = $row['pilotID']; $id = $_GET['id']; That's what's before and after it. this code is irrelevant without the header, oh my there are some characters on phpf today! Quote Link to comment https://forums.phpfreaks.com/topic/243959-header/#findComment-1252682 Share on other sites More sharing options...
dudejma Posted August 5, 2011 Author Share Posted August 5, 2011 That comes later. It's a lot of code. But basically, if the query works, it goes to that page. I'll post the whole code. if(!isset($adminid) || !isset($adminpass) || !isset($position)) { header("Location: index.php"); } $pilotid = $row['pilotID']; $id = $_GET['id']; $sql = "SELECT * FROM pireps WHERE id=$id"; $result = mysql_query($sql); $row = mysql_fetch_array($result); if (isset($_POST['submit'])) { $flight = mysql_escape_string($_POST['flight']); $dept = mysql_escape_string(strtoupper($_POST['dept'])); $arrival = mysql_escape_string(strtoupper($_POST['arrival'])); $flightTime = mysql_escape_string($_POST['flightTime']); $fuel = mysql_escape_string($_POST['fuel']); $aircraft = $_POST['aircraft']; $status = $_POST['status']; $comments = $_POST['comments']; if (empty($flight)) { $errors .= "Please enter the flight number. <br />"; } if (empty($dept)) { $errors .= "Please enter the departure airport. <br />"; } if (empty($arrival)) { $errors .= "Please enter the arrival airport. <br />"; } if ($flightTime == "") { $errors .= "Please enter the flight time. <br />"; } if (empty($fuel)) { $errors .= "Please enter the fuel. <br />"; } if ($errors == "") { $sql2 = "UPDATE pireps SET flight = '$flight', $dept = '$dept', arrival = '$arrival', flightTime = '$flightTime', fuel = '$fuel', aircraft = '$aircraft', status='$status' comment = '$comment' WHERE id='$id'" or die("An error has occured. Please contact the webmaster with the following error: " . mysql_error()); $result2 = mysql_query($sql2); header("Location: logbook.php?pid=" . $pilotid); } else {} } ?> The update doesn't work anyway, but that's for another topic. lol Quote Link to comment https://forums.phpfreaks.com/topic/243959-header/#findComment-1252687 Share on other sites More sharing options...
Pikachu2000 Posted August 5, 2011 Share Posted August 5, 2011 The update doesn't work anyway, but that's for another topic. lol Probably has at least something to do with this: $dept = '$dept', Every time you use a header() redirect, it should be immediately followed by a call to exit() to stop any further execution of code in the script. Quote Link to comment https://forums.phpfreaks.com/topic/243959-header/#findComment-1252693 Share on other sites More sharing options...
dudejma Posted August 5, 2011 Author Share Posted August 5, 2011 Oh, missed that one, thanks Pikachu! So I put exit() under header or outside of the if statement? Quote Link to comment https://forums.phpfreaks.com/topic/243959-header/#findComment-1252695 Share on other sites More sharing options...
Pikachu2000 Posted August 5, 2011 Share Posted August 5, 2011 Immediately after the header() call. header('Location: index.php'); exit(); Quote Link to comment https://forums.phpfreaks.com/topic/243959-header/#findComment-1252699 Share on other sites More sharing options...
dudejma Posted August 5, 2011 Author Share Posted August 5, 2011 I did that and it still doesn't work. I also fixed the UPDATE query and it still doesn't work. Quote Link to comment https://forums.phpfreaks.com/topic/243959-header/#findComment-1252707 Share on other sites More sharing options...
AyKay47 Posted August 5, 2011 Share Posted August 5, 2011 what i notice is that you do not initiate the $errors variable before trying to concatenate values onto it.. $errors = ""; if (empty($flight)) {$errors .= "Please enter the flight number. <br />";}if (empty($dept)) {$errors .= "Please enter the departure airport. <br />";}if (empty($arrival)) {$errors .= "Please enter the arrival airport. <br />";}if ($flightTime == "") {$errors .= "Please enter the flight time. <br />";}if (empty($fuel)) {$errors .= "Please enter the fuel. <br />";}if ($errors == "") {$sql2 = "UPDATE pireps SET flight = '$flight', $dept = '$dept', arrival = '$arrival', flightTime = '$flightTime', fuel = '$fuel', aircraft = '$aircraft', status='$status' comment = '$comment' WHERE id='$id'"or die("An error has occured. Please contact the webmaster with the following error: " . mysql_error());$result2 = mysql_query($sql2);header("Location: logbook.php?pid=" . $pilotid);} else {}} Quote Link to comment https://forums.phpfreaks.com/topic/243959-header/#findComment-1252720 Share on other sites More sharing options...
dudejma Posted August 5, 2011 Author Share Posted August 5, 2011 Woops. Left out that part. It's there, it was just at the very top: <?php session_start(); require 'include/sql.php'; $errors = ""; $adminid = $_SESSION['adminid']; $adminpass = $_SESSION['adminpass']; $position = $_SESSION['position']; Quote Link to comment https://forums.phpfreaks.com/topic/243959-header/#findComment-1252726 Share on other sites More sharing options...
AyKay47 Posted August 5, 2011 Share Posted August 5, 2011 okay, $pilotid should be usable throughout the entire script since it is defined in the global scope...as to the reason your update query is not working, you have storing the "or die" part in your variable too, then trying to query that as well, should be written as such if ($errors == "") { $sql2 = "UPDATE pireps SET flight = '$flight', dept = '$dept', arrival = '$arrival', flightTime = '$flightTime', fuel = '$fuel', aircraft = '$aircraft', status='$status' comment = '$comment' WHERE id='$id'" $result2 = mysql_query($sql2) or die("An error has occured. Please contact the webmaster with the following error: " . mysql_error()); header("Location: logbook.php?pid=" . $pilotid); } else {} Quote Link to comment https://forums.phpfreaks.com/topic/243959-header/#findComment-1252740 Share on other sites More sharing options...
dudejma Posted August 5, 2011 Author Share Posted August 5, 2011 I added that but when it redirects, it still goes to logbook.php without the pid. I echoed the query and found that the problem is that it can't find the id part. But I don't know why because earlier in the script, I use $id and it works perfectly fine. Here's my full script with your add-on AyKay. <?php session_start(); require 'include/sql.php'; $errors = ""; $adminid = $_SESSION['adminid']; $adminpass = $_SESSION['adminpass']; $position = $_SESSION['position']; if(!isset($adminid) || !isset($adminpass) || !isset($position)) { header("Location: index.php"); } $pilotid = $row['pilotID']; $id = $_GET['id']; $sql = "SELECT * FROM pireps WHERE id=$id"; $result = mysql_query($sql); $row = mysql_fetch_array($result); $flightNum = $row['flight']; $departure = $row['dept']; $arrivalAirport = $row['arrival']; $hours = $row['flightTime']; $fuelUsed = $row['fuel']; $aircraftUsed = $row['aircraft']; $statusPirep = $row['status']; $pilotComment = $row['comment']; if (isset($_POST['submit'])) { $flight = mysql_escape_string($_POST['flight']); $dept = mysql_escape_string(strtoupper($_POST['dept'])); $arrival = mysql_escape_string(strtoupper($_POST['arrival'])); $flightTime = mysql_escape_string($_POST['flightTime']); $fuel = mysql_escape_string($_POST['fuel']); $aircraft = $_POST['aircraft']; $status = $_POST['status']; $comments = $_POST['comments']; $sql2 = "UPDATE pireps SET flight='$flight', dept='$dept', arrival='$arrival', flightTime='$flightTime', fuel='$fuel', aircraft='$aircraft', status='$status', comments='$comment' WHERE id='$id'"; $result2 = mysql_query($sql2) or die("An error has occured. Please contact the webmaster with the following error: " . mysql_error());;header("Location: logbook.php?pid=" . $pilotid); } else {} ?> Quote Link to comment https://forums.phpfreaks.com/topic/243959-header/#findComment-1252744 Share on other sites More sharing options...
AyKay47 Posted August 5, 2011 Share Posted August 5, 2011 you are using a query value in $pilotid before actually calling the query.. $id = $_GET['id']; $sql = "SELECT * FROM pireps WHERE id=$id"; $result = mysql_query($sql); $row = mysql_fetch_array($result); $pilotid = $row['pilotID']; //specify pilotid here $flightNum = $row['flight']; $departure = $row['dept']; $arrivalAirport = $row['arrival']; $hours = $row['flightTime']; $fuelUsed = $row['fuel']; $aircraftUsed = $row['aircraft']; $statusPirep = $row['status']; $pilotComment = $row['comment']; then your logbook.php should have the pid appended correctly Quote Link to comment https://forums.phpfreaks.com/topic/243959-header/#findComment-1252752 Share on other sites More sharing options...
dudejma Posted August 5, 2011 Author Share Posted August 5, 2011 I moved it and it still doesn't carry over the pid. Quote Link to comment https://forums.phpfreaks.com/topic/243959-header/#findComment-1252761 Share on other sites More sharing options...
phpSensei Posted August 5, 2011 Share Posted August 5, 2011 if you don't mind post your updated code, I'll take a look over. I mean you FULL code not just a piece of the page/. Quote Link to comment https://forums.phpfreaks.com/topic/243959-header/#findComment-1252793 Share on other sites More sharing options...
dudejma Posted August 5, 2011 Author Share Posted August 5, 2011 <?php session_start(); require 'include/sql.php'; $errors = ""; $adminid = $_SESSION['adminid']; $adminpass = $_SESSION['adminpass']; $position = $_SESSION['position']; if(!isset($adminid) || !isset($adminpass) || !isset($position)) { header("Location: index.php"); } $id = $_GET['id']; $sql = "SELECT * FROM pireps WHERE id=$id"; $result = mysql_query($sql); $row = mysql_fetch_array($result); $pilotid = $row['pilotID']; $flightNum = $row['flight']; $departure = $row['dept']; $arrivalAirport = $row['arrival']; $hours = $row['flightTime']; $fuelUsed = $row['fuel']; $aircraftUsed = $row['aircraft']; $statusPirep = $row['status']; $pilotComment = $row['comment']; if (isset($_POST['submit'])) { $flight = mysql_escape_string($_POST['flight']); $dept = mysql_escape_string(strtoupper($_POST['dept'])); $arrival = mysql_escape_string(strtoupper($_POST['arrival'])); $flightTime = mysql_escape_string($_POST['flightTime']); $fuel = mysql_escape_string($_POST['fuel']); $aircraft = $_POST['aircraft']; $status = $_POST['status']; $comments = $_POST['comments']; $sql2 = "UPDATE pireps SET flight='$flight', dept='$dept', arrival='$arrival', flightTime='$flightTime', fuel='$fuel', aircraft='$aircraft', status='$status', comments='$comment' WHERE id='$id'"; $result2 = mysql_query($sql2) or die("An error has occured. Please contact the webmaster with the following error: " . mysql_error());;header("Location: logbook.php?pid=" . $pilotid); } else {} ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" type="text/css" href="css/styles.css" /> <script language="javascript" type="text/javascript"> function limitText(limitField, limitCount, limitNum) { if (limitField.value.length > limitNum) { limitField.value = limitField.value.substring(0, limitNum); } else { limitCount.value = limitNum - limitField.value.length; } } </script> <title>VAAdministration Center</title> </head> <body> <!-- Begins Wrapper --> <div id="wrapper"> <!-- Begins Header --> <div id="header"> <center> <img src="images/aadmin.jpg" /> </center> </div> <!-- Ends header --> <!-- Begins Faux --> <div id="faux"> <!-- Begins left column --> <div id="leftcolumn"> <br /> <?php include 'include/menu.php'; ?> </div> <!-- Ends left column --> <!-- Begins content --> <div id="content"> <center> <!-- Begins page title --> <br /> <font color="red" size="6"><b>Edit </font><font color="blue" size="6">PIREP</b></font> <br /> <br /> <br /> <?php echo $errors; ?> <table border="0" cellpadding="4" cellspacing="4"> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <tr> <td><b>Flight Number: </b></td> <td><input type="text" size="8" value="<?php echo $flightNum; ?>" name="flight" maxlength="7"/></td> </tr> <tr> <td><b>Departure Airport (ICAO): </b></td> <td><input type="text" size="4" value="<?php echo $departure; ?>" name="dept" maxlength="4"/></td> </tr> <tr> <td><b>Arrival Airport (ICAO): </b></td> <td><input type="text" size="4" value="<?php echo $arrivalAirport; ?>" name="arrival" maxlength="4"/></td> </tr> <tr> <td><b>Flight Time</b></td> <td><input type="text" size="1" value="<?php echo $hours; ?>" name="flightTime" maxlength="4" /></td> </tr> <tr> <td><b>Fuel (lbs.): </b></td> <td><input type="text" size="10" value="<?php echo $fuelUsed; ?>" name="fuel" maxlength="6"/></td> </tr> <tr> <td><b>Aircraft: </b></td> <td><select name="aircraft"> <option value="ATR-72" <?php if ($aircraftUsed == 'ATR-72') echo 'selected="selected"'; ?>>ATR-72</option> <option value="ERJ-135" <?php if ($aircraftUsed == 'ERJ-135') echo 'selected="selected"'; ?>>ERJ-135</option> <option value="ERJ-140" <?php if ($aircraftUsed == 'ERJ-140') echo 'selected="selected"'; ?>>ERJ-140</option> <option value="ERJ-145" <?php if ($aircraftUsed == 'ERJ-145') echo 'selected="selected"'; ?>>ERJ-145</option> <option value="CRJ-700" <?php if ($aircraftUsed == 'CRJ-700') echo 'selected="selected"'; ?>>CRJ-700</option> <option value="MD-80" <?php if ($aircraftUsed == 'MD-80') echo 'selected="selected"'; ?>>McDonnel Douglas MD-80</option> <option value="B737" <?php if ($aircraftUsed == 'B737') echo 'selected="selected"'; ?>>Boeing 737-800</option> <option value="B757" <?php if ($aircraftUsed == 'B757') echo 'selected="selected"'; ?>>Boeing 757</option> <option value="B767" <?php if ($aircraftUsed == 'B767') echo 'selected="selected"'; ?>>Boeing 767</option> <option value="B777" <?php if ($aircraftUsed == 'B777') echo 'selected="selected"'; ?>>Boeing 777</option> </select></td> </tr> <tr> <td><b>Status: </b></td> <td><select name="status"> <option value="1" <?php if ($statusPirep == '1') echo 'selected="selected"'; ?>>Approved</option> <option value="2" <?php if ($statusPirep == '2') echo 'selected="selected"'; ?>>Declined</option></select></td> </tr> <tr> <td><b>Comments: </b> <td><textarea cols="20" rows="15" name="comments" onKeyDown="limitText(this.form.comments,this.form.countdown,350);" onKeyUp="limitText(this.form.comments,this.form.countdown,350);"><?php echo $pilotComment; ?></textarea><br> You have <input readonly type="text" name="countdown" size="3" value="350"> characters left.</font></td> </td> </tr> <tr> <td></td> <td><input type="submit" value="Submit" name="submit" class="myButton"/></td> </tr> </table> </form> </center> <!-- DO NOT TOUCH --> <br /> <!-- DONE --> </div> <!-- Begins right column --> <div id="rightcolumn"> <br /> </div> <!-- Ends right column --> <!-- Begins footer --> <div id="footer"> <center> <?php include 'include/footer.php'; ?> </center> </div> <!-- Ends footer --> </div> </div> </body> </html> There ya go. Sorry to put you guys through so much trouble. Thanks all of you! Quote Link to comment https://forums.phpfreaks.com/topic/243959-header/#findComment-1252798 Share on other sites More sharing options...
phpSensei Posted August 5, 2011 Share Posted August 5, 2011 Alright I wrote a debugging version of your code, let me know the outputs you see on the screen <?php session_start(); ini_set ("display_errors", "1"); error_reporting(E_ALL); require 'include/sql.php'; $errors = ""; $adminid = $_SESSION['adminid']; $adminpass = $_SESSION['adminpass']; $position = $_SESSION['position']; if(!isset($adminid) || !isset($adminpass) || !isset($position)) { header("Location: index.php"); } $id = $_GET['id']; $sql = "SELECT * FROM pireps WHERE `id` = $id"; $result = mysql_query($sql); $row = mysql_fetch_array($result); $pilotid = $row['pilotID']; $flightNum = $row['flight']; $departure = $row['dept']; $arrivalAirport = $row['arrival']; $hours = $row['flightTime']; $fuelUsed = $row['fuel']; $aircraftUsed = $row['aircraft']; $statusPirep = $row['status']; $pilotComment = $row['comment']; print "THE VALUE OF PILOT ID IS: ". $pilotid; if (isset($_POST['submit'])) { $flight = mysql_escape_string($_POST['flight']); $dept = mysql_escape_string(strtoupper($_POST['dept'])); $arrival = mysql_escape_string(strtoupper($_POST['arrival'])); $flightTime = mysql_escape_string($_POST['flightTime']); $fuel = mysql_escape_string($_POST['fuel']); $aircraft = $_POST['aircraft']; $status = $_POST['status']; $comments = $_POST['comments']; $sql2 = "UPDATE pireps SET flight='$flight', dept='$dept', arrival='$arrival', flightTime='$flightTime', fuel='$fuel', aircraft='$aircraft', status='$status', comments='$comment' WHERE `id` = '$id' "; $result2 = mysql_query($sql2) or die("An error has occured. Please contact the webmaster with the following error: " . mysql_error()); print "THE VALUE OF PILOT ID IS: ". $pilotid; #header("Location: logbook.php?pid=" . $pilotid); } else { print "Form was not submitted"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" type="text/css" href="css/styles.css" /> <script language="javascript" type="text/javascript"> function limitText(limitField, limitCount, limitNum) { if (limitField.value.length > limitNum) { limitField.value = limitField.value.substring(0, limitNum); } else { limitCount.value = limitNum - limitField.value.length; } } </script> <title>VAAdministration Center</title> </head> <body> <!-- Begins Wrapper --> <div id="wrapper"> <!-- Begins Header --> <div id="header"> <center> <img src="images/aadmin.jpg" /> </center> </div> <!-- Ends header --> <!-- Begins Faux --> <div id="faux"> <!-- Begins left column --> <div id="leftcolumn"> <br /> <?php include 'include/menu.php'; ?> </div> <!-- Ends left column --> <!-- Begins content --> <div id="content"> <center> <!-- Begins page title --> <br /> <font color="red" size="6"><b>Edit </font><font color="blue" size="6">PIREP</b></font> <br /> <br /> <br /> <?php echo $errors; ?> <table border="0" cellpadding="4" cellspacing="4"> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <tr> <td><b>Flight Number: </b></td> <td><input type="text" size="8" value="<?php echo $flightNum; ?>" name="flight" maxlength="7"/></td> </tr> <tr> <td><b>Departure Airport (ICAO): </b></td> <td><input type="text" size="4" value="<?php echo $departure; ?>" name="dept" maxlength="4"/></td> </tr> <tr> <td><b>Arrival Airport (ICAO): </b></td> <td><input type="text" size="4" value="<?php echo $arrivalAirport; ?>" name="arrival" maxlength="4"/></td> </tr> <tr> <td><b>Flight Time</b></td> <td><input type="text" size="1" value="<?php echo $hours; ?>" name="flightTime" maxlength="4" /></td> </tr> <tr> <td><b>Fuel (lbs.): </b></td> <td><input type="text" size="10" value="<?php echo $fuelUsed; ?>" name="fuel" maxlength="6"/></td> </tr> <tr> <td><b>Aircraft: </b></td> <td><select name="aircraft"> <option value="ATR-72" <?php if ($aircraftUsed == 'ATR-72') echo 'selected="selected"'; ?>>ATR-72</option> <option value="ERJ-135" <?php if ($aircraftUsed == 'ERJ-135') echo 'selected="selected"'; ?>>ERJ-135</option> <option value="ERJ-140" <?php if ($aircraftUsed == 'ERJ-140') echo 'selected="selected"'; ?>>ERJ-140</option> <option value="ERJ-145" <?php if ($aircraftUsed == 'ERJ-145') echo 'selected="selected"'; ?>>ERJ-145</option> <option value="CRJ-700" <?php if ($aircraftUsed == 'CRJ-700') echo 'selected="selected"'; ?>>CRJ-700</option> <option value="MD-80" <?php if ($aircraftUsed == 'MD-80') echo 'selected="selected"'; ?>>McDonnel Douglas MD-80</option> <option value="B737" <?php if ($aircraftUsed == 'B737') echo 'selected="selected"'; ?>>Boeing 737-800</option> <option value="B757" <?php if ($aircraftUsed == 'B757') echo 'selected="selected"'; ?>>Boeing 757</option> <option value="B767" <?php if ($aircraftUsed == 'B767') echo 'selected="selected"'; ?>>Boeing 767</option> <option value="B777" <?php if ($aircraftUsed == 'B777') echo 'selected="selected"'; ?>>Boeing 777</option> </select></td> </tr> <tr> <td><b>Status: </b></td> <td><select name="status"> <option value="1" <?php if ($statusPirep == '1') echo 'selected="selected"'; ?>>Approved</option> <option value="2" <?php if ($statusPirep == '2') echo 'selected="selected"'; ?>>Declined</option></select></td> </tr> <tr> <td><b>Comments: </b> <td><textarea cols="20" rows="15" name="comments" onKeyDown="limitText(this.form.comments,this.form.countdown,350);" onKeyUp="limitText(this.form.comments,this.form.countdown,350);"><?php echo $pilotComment; ?></textarea><br> You have <input readonly type="text" name="countdown" size="3" value="350"> characters left.</font></td> </td> </tr> <tr> <td></td> <td><input type="submit" value="Submit" name="submit" class="myButton"/></td> </tr> </table> </form> </center> <!-- DO NOT TOUCH --> <br /> <!-- DONE --> </div> <!-- Begins right column --> <div id="rightcolumn"> <br /> </div> <!-- Ends right column --> <!-- Begins footer --> <div id="footer"> <center> <?php include 'include/footer.php'; ?> </center> </div> <!-- Ends footer --> </div> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/243959-header/#findComment-1252802 Share on other sites More sharing options...
dudejma Posted August 5, 2011 Author Share Posted August 5, 2011 Here's the errors: Notice: Undefined index: id in /home/virtuala/public_html/site/admin/editPirep.php on line 20 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/virtuala/public_html/site/admin/editPirep.php on line 24 THE VALUE OF PILOT ID IS: Notice: Undefined variable: comment in /home/virtuala/public_html/site/admin/editPirep.php on line 48 THE VALUE OF PILOT ID IS: Quote Link to comment https://forums.phpfreaks.com/topic/243959-header/#findComment-1252818 Share on other sites More sharing options...
AyKay47 Posted August 5, 2011 Share Posted August 5, 2011 well the root of your issue is that your script is running as if $_GET['id'] has a value, even if it is not set, check to see if $_GET['id'] has been set first, then run the dependent code.. Quote Link to comment https://forums.phpfreaks.com/topic/243959-header/#findComment-1252820 Share on other sites More sharing options...
phpSensei Posted August 5, 2011 Share Posted August 5, 2011 Alright, lets see what the cause of the mysql error is. try this and let me know the ouput. <?php session_start(); ini_set ("display_errors", "1"); error_reporting(E_ALL ^ E_NOTICE); require 'include/sql.php'; $errors = ""; $adminid = $_SESSION['adminid']; $adminpass = $_SESSION['adminpass']; $position = $_SESSION['position']; if(!isset($adminid) || !isset($adminpass) || !isset($position)) { header("Location: index.php"); } $id = $_GET['id']; $sql = "SELECT * FROM pireps WHERE `id` = $id"; $result = mysql_query($sql); die(mysql_error()); $row = mysql_fetch_array($result); $pilotid = $row['pilotID']; $flightNum = $row['flight']; $departure = $row['dept']; $arrivalAirport = $row['arrival']; $hours = $row['flightTime']; $fuelUsed = $row['fuel']; $aircraftUsed = $row['aircraft']; $statusPirep = $row['status']; $pilotComment = $row['comment']; print "THE VALUE OF PILOT ID IS: ". $pilotid; if (isset($_POST['submit'])) { $flight = mysql_escape_string($_POST['flight']); $dept = mysql_escape_string(strtoupper($_POST['dept'])); $arrival = mysql_escape_string(strtoupper($_POST['arrival'])); $flightTime = mysql_escape_string($_POST['flightTime']); $fuel = mysql_escape_string($_POST['fuel']); $aircraft = $_POST['aircraft']; $status = $_POST['status']; $comments = $_POST['comments']; $sql2 = "UPDATE pireps SET flight='$flight', dept='$dept', arrival='$arrival', flightTime='$flightTime', fuel='$fuel', aircraft='$aircraft', status='$status', comments='$comment' WHERE `id` = '$id' "; $result2 = mysql_query($sql2) or die("An error has occured. Please contact the webmaster with the following error: " . mysql_error()); print "THE VALUE OF PILOT ID IS: ". $pilotid; #header("Location: logbook.php?pid=" . $pilotid); } else { print "Form was not submitted"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" type="text/css" href="css/styles.css" /> <script language="javascript" type="text/javascript"> function limitText(limitField, limitCount, limitNum) { if (limitField.value.length > limitNum) { limitField.value = limitField.value.substring(0, limitNum); } else { limitCount.value = limitNum - limitField.value.length; } } </script> <title>VAAdministration Center</title> </head> <body> <!-- Begins Wrapper --> <div id="wrapper"> <!-- Begins Header --> <div id="header"> <center> <img src="images/aadmin.jpg" /> </center> </div> <!-- Ends header --> <!-- Begins Faux --> <div id="faux"> <!-- Begins left column --> <div id="leftcolumn"> <br /> <?php include 'include/menu.php'; ?> </div> <!-- Ends left column --> <!-- Begins content --> <div id="content"> <center> <!-- Begins page title --> <br /> <font color="red" size="6"><b>Edit </font><font color="blue" size="6">PIREP</b></font> <br /> <br /> <br /> <?php echo $errors; ?> <table border="0" cellpadding="4" cellspacing="4"> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <tr> <td><b>Flight Number: </b></td> <td><input type="text" size="8" value="<?php echo $flightNum; ?>" name="flight" maxlength="7"/></td> </tr> <tr> <td><b>Departure Airport (ICAO): </b></td> <td><input type="text" size="4" value="<?php echo $departure; ?>" name="dept" maxlength="4"/></td> </tr> <tr> <td><b>Arrival Airport (ICAO): </b></td> <td><input type="text" size="4" value="<?php echo $arrivalAirport; ?>" name="arrival" maxlength="4"/></td> </tr> <tr> <td><b>Flight Time</b></td> <td><input type="text" size="1" value="<?php echo $hours; ?>" name="flightTime" maxlength="4" /></td> </tr> <tr> <td><b>Fuel (lbs.): </b></td> <td><input type="text" size="10" value="<?php echo $fuelUsed; ?>" name="fuel" maxlength="6"/></td> </tr> <tr> <td><b>Aircraft: </b></td> <td><select name="aircraft"> <option value="ATR-72" <?php if ($aircraftUsed == 'ATR-72') echo 'selected="selected"'; ?>>ATR-72</option> <option value="ERJ-135" <?php if ($aircraftUsed == 'ERJ-135') echo 'selected="selected"'; ?>>ERJ-135</option> <option value="ERJ-140" <?php if ($aircraftUsed == 'ERJ-140') echo 'selected="selected"'; ?>>ERJ-140</option> <option value="ERJ-145" <?php if ($aircraftUsed == 'ERJ-145') echo 'selected="selected"'; ?>>ERJ-145</option> <option value="CRJ-700" <?php if ($aircraftUsed == 'CRJ-700') echo 'selected="selected"'; ?>>CRJ-700</option> <option value="MD-80" <?php if ($aircraftUsed == 'MD-80') echo 'selected="selected"'; ?>>McDonnel Douglas MD-80</option> <option value="B737" <?php if ($aircraftUsed == 'B737') echo 'selected="selected"'; ?>>Boeing 737-800</option> <option value="B757" <?php if ($aircraftUsed == 'B757') echo 'selected="selected"'; ?>>Boeing 757</option> <option value="B767" <?php if ($aircraftUsed == 'B767') echo 'selected="selected"'; ?>>Boeing 767</option> <option value="B777" <?php if ($aircraftUsed == 'B777') echo 'selected="selected"'; ?>>Boeing 777</option> </select></td> </tr> <tr> <td><b>Status: </b></td> <td><select name="status"> <option value="1" <?php if ($statusPirep == '1') echo 'selected="selected"'; ?>>Approved</option> <option value="2" <?php if ($statusPirep == '2') echo 'selected="selected"'; ?>>Declined</option></select></td> </tr> <tr> <td><b>Comments: </b> <td><textarea cols="20" rows="15" name="comments" onKeyDown="limitText(this.form.comments,this.form.countdown,350);" onKeyUp="limitText(this.form.comments,this.form.countdown,350);"><?php echo $pilotComment; ?></textarea><br> You have <input readonly type="text" name="countdown" size="3" value="350"> characters left.</font></td> </td> </tr> <tr> <td></td> <td><input type="submit" value="Submit" name="submit" class="myButton"/></td> </tr> </table> </form> </center> <!-- DO NOT TOUCH --> <br /> <!-- DONE --> </div> <!-- Begins right column --> <div id="rightcolumn"> <br /> </div> <!-- Ends right column --> <!-- Begins footer --> <div id="footer"> <center> <?php include 'include/footer.php'; ?> </center> </div> <!-- Ends footer --> </div> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/243959-header/#findComment-1252821 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.