Jump to content

issue with php edit page


ianhaney50
Go to solution Solved by ianhaney50,

Recommended Posts

Hi

I 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 now

Thank you in advance

 

would the issue be with this page or the view tracking php page where the records are displayed?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.