ianhaney50 Posted October 31, 2015 Share Posted October 31, 2015 HiI am trying to populate a form ready to update the data and have managed to get the id number displaying in the input field but for every other input field, it displays the following<br /><b>Notice</b>: Undefined index: customer_name in <b>/home/sites/it-doneright.co.uk/public_html/admin/repairs-tracking/edit-repair-tracking.php</b> on line <b>40</b><br />I really don't get it or see where I am going wrong with it, below is the whole code on the edit-repair-tracking.php page <form action="update-admin-repair-tracking.php" method="post"> Repair ID: <input value="<?= $_GET['id'] ?>" name="id"/> Customer Name: <input type="text" name="customer_name" value="<?= $_GET['customer_name'] ?>"> Customer Email: <input type="text" name="customer_email" value="<?= $_GET['customer_email'] ?>"> Customer Phone: <input type="text" name="customer_phone" value="<?= $_GET['customer_phone'] ?>"> Computer Make: <input type="text" name="computer_make" value="<?= $_GET['computer_make'] ?>"> Computer Model: <input type="text" name="computer_model" value="<?= $_GET['computer_model'] ?>"> Technician: <select name="technician" id="technician"> <option value="Not Assigned">Not Assigned</option> <option value="Phil Roskams">Phil Roskams</option> <option value="Ian Haney">Ian Haney</option> </select> Status: <select name="status" id="status"> <option value="Not Started">Not Started</option> <option value="In Queue">In Queue</option> <option value="On Bench / Working">On Bench / Working</option> <option value="Awaiting Parts">Awaiting Parts</option> <option value="Awaiting Customer">Awaiting Customer</option> <option value="Completed">Completed</option> </select> Expected Repair Date: <input type="date" name="exrdate" value="<?= $_GET['exrdate'] ?>"> Expected Repair Time: <input type="time" name="exrtime" value="<?= $_GET['exrtime'] ?>"> Expected Start Date<input type="date" name="exstdate" value="<?= $_GET['exstdate'] ?>"> Expected Start Time: <input type="time" name="exstime" value="<?= $_GET['exstime'] ?>"> Delivery Type: <select name="deltype" id="deltype"> <option value="Self Pickup">Self Pickup</option> <option value="Deliver to Customer">Delivery to Customer</option> </select> Comments: <br> <textarea name="comments" cols="50" rows="3" id="comments"><?= $_GET['comments'] ?></textarea> <input type="submit" name="submit"> </form> </body> </html> Can someone help me please as been trying to work out what I am missing for a good hour nowThank you in advance would the issue be with this page or the view tracking php page where the records are displayed? Quote Link to comment https://forums.phpfreaks.com/topic/298958-issue-with-php-edit-page/ Share on other sites More sharing options...
element121 Posted October 31, 2015 Share Posted October 31, 2015 Hi Ian, Try var_dump($_GET) at the top of this page and you will see what GET contains. It looks like the variables aren't being passed from the page that calls this page. GET may not be the best way to pass all the variables to another page, if this data is coming from the database, it might be better to use that. Hope that helps, Jon Quote Link to comment https://forums.phpfreaks.com/topic/298958-issue-with-php-edit-page/#findComment-1524955 Share on other sites More sharing options...
ianhaney50 Posted October 31, 2015 Author Share Posted October 31, 2015 Hi I have added in the var dump line and that outputs the following array(1) { ["id"]=> string(2) "20" } So $_POST is better then, that right? If so do I just change $_GET to $_POST Quote Link to comment https://forums.phpfreaks.com/topic/298958-issue-with-php-edit-page/#findComment-1524956 Share on other sites More sharing options...
ianhaney50 Posted October 31, 2015 Author Share Posted October 31, 2015 Below is the view page that calls the edit page <?php $host = ''; $user = ''; $password = ''; $dname = ''; $db = new mysqli($host, $user, $password, $dname); if ($db->connect_errno) { echo "Failed to connect to MySQL: (" . $db->connect_errno . ") " . $db->connect_error; } $sql = "SELECT id, customer_name, customer_email, customer_phone, computer_make, computer_model, technician, status, exrdate, exrtime, exstdate, exstime, deltype, comments FROM repairs"; $result_db = $db->query($sql) or die('Error perform query!'); ?> <table border="1"> <tr> <th>Repair ID</th> <th>Customer Name</th> <th>Customer Email</th> <th>Customer Phone</th> <th>Computer Make</th> <th>Computer Model</th> <th>Technician</th> <th>Status</th> <th>Expected Repair Date</th> <th>Expected Repair Time</th> <th>Expected Start Date</th> <th>Expected Start Time</th> <th>Delivery Type</th> <th>Comments</th> <th>Update</th> </tr> <?php while ($r = $result_db->fetch_object()) { $update = "admin/repairs-tracking/edit-repair-tracking.php?id={$r->id}"; echo '<tr>'; echo '<td>' . $r->id . '</td>'; echo '<td>' . $r->customer_name . '</td>'; echo '<td>' . $r->customer_email . '</td>'; echo '<td>' . $r->customer_phone . '</td>'; echo '<td>' . $r->computer_make . '</td>'; echo '<td>' . $r->computer_model . '</td>'; echo '<td>' . $r->technician . '</td>'; echo '<td>' . $r->status . '</td>'; echo '<td>' . $r->exrdate . '</td>'; echo '<td>' . $r->exrtime . '</td>'; echo '<td>' . $r->exstdate . '</td>'; echo '<td>' . $r->exstime . '</td>'; echo '<td>' . $r->deltype . '</td>'; echo '<td>' . $r->comments . '</td>'; echo "<td><a href='/{$update}'>Update</a></td>"; echo '</tr>'; } $db->close(); ?> </table> Quote Link to comment https://forums.phpfreaks.com/topic/298958-issue-with-php-edit-page/#findComment-1524957 Share on other sites More sharing options...
ianhaney50 Posted October 31, 2015 Author Share Posted October 31, 2015 I did notice the form on the edit page has the method post instead of get so am guessing is best to replace $_GET with $_POST Quote Link to comment https://forums.phpfreaks.com/topic/298958-issue-with-php-edit-page/#findComment-1524958 Share on other sites More sharing options...
Solution ianhaney50 Posted October 31, 2015 Author Solution Share Posted October 31, 2015 Sorry have it solved now Quote Link to comment https://forums.phpfreaks.com/topic/298958-issue-with-php-edit-page/#findComment-1524964 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.