Undefined Index while trying to update form

i keep getting undefined Index while trying to update my form, but I have no idea what to change.

edit.php

 <?php
 include('/includes/connection.inc.php');

// create database connection
$conn=mysqli_connect(‘localhost’, ‘root’, ‘root’, ‘phpsols’);
$id = $_GET[“id”];
$result = mysqli_query($conn, “SELECT * FROM feedback WHERE bride_id=’$id’”);
$row = mysqli_fetch_array($result);
?>

   <tr>       
     <td>Name</td>
     <td>
        <input type="text" name="Name" size="25" 
        value="<?php echo "$row[Name]";?>">
     </td>
   </tr>
   <tr>
     <td>State</td>
      <td>
       <input type="text" name="State" size="25"
     value="<?php echo "$row[State]";?>">
      </td>
          <td>Feedback</td>
      <td>
       <textarea name="Feedback" cols="60" rows="8"><?php echo "$row[Feedback]"; ?></textarea>
      </td>
    </tr>
    <tr>
     <td>
       <input type="hidden" name="id" value="<?php echo "$row[bride_id]" ?>">
       <input type="submit" name="id" value="Edit" >

edit_form.php

<?php // Get IDs $id = $_GET['id']; // Edit the product from the database require_once('connection.inc.php'); // create database connection $conn=mysqli_connect('localhost', 'root', 'root', 'phpsols'); $sql = "UPDATE feedback WHERE bride_id = '$id'"; If($result = mysqli_query($conn,$sql)) { header('Location: http://iplaneventsatl.com/list.php'); exit; } ?>

Within edit_form.php you use
$id = $_GET[‘id’];

But when the form submits it submits to “http://iplaneventsatl.com/includes/edit_form.php
change this to “http://iplaneventsatl.com/includes/edit_form.php?id=<?php echo "$row[bride_id]";?>”

Also, it would be beneficial to add some check for security. http://iplaneventsatl.com/includes/edit.php?id=* is accessible to anyone.

also need to switch get to post since thats what you have as the method. really need to add some injection protection too.

thanks!

I did what you all said. It now has the id, but when I hit submit, edit_form.php is still blank and doesn’t redirect. Is anything else missing?

i will add security very soon.

I got it! Thank you so much :slight_smile:
Securing it now

Sponsor our Newsletter | Privacy Policy | Terms of Service