0

I tried reading all the other topics on this, but nothing was too close to what I need. So, if I missed something somewhere, sorry, but for now, I'm having a common issue and can't find a solution.

I made a form that connects to my database to edit news articles that I have posted. Everything is working fine when it comes to functionality and getting the data, but my issue is really trying to submit my edit.

This is the form itself:

<form method="get" action="/index.php?page=editnews&id=$row[id]">
  <div><label>id</label><input type="text" name="id" id="id" value="<?= $row['id']?>" readonly/></div>
  <div><label>Header</label><input type="text" name="header" id="header" value="<?= $row['header']?>"/></div>
  <div><label>Story</label><textarea type="text" name="story" id="story" cols="10" rows="20" wrap="soft"><?= $row['story']?></textarea></div>
  <input type="submit" value="Submit">
</form>

When I hit submit, it only takes me to "index.php=id". It's skipping the whole "page=editnews" part after index.php.

What am I missing here?

  • Also, since you already have the `id` as a form field, why would you need to pass it in the URL as well? Just add the page as a hidden input and you'll be fine. – El_Vanja Feb 08 '21 at 11:49
  • This did work. Thank you very much for that. I saw that during one of my searches, but didn't think it would apply to my situation. So thank you very much for this =D The reason I'm passing it in the URL is so it just redirects back to the edit page of the specific article I was editing. – Jakob Glantz Feb 08 '21 at 17:38

1 Answers1

0

Replace the below

<form method="get" action="/index.php?page=editnews&id=$row[id]">

with

<form method="get" action="/index.php?page=editnews&id=<?php echo $row[id]; ?>">
John Doe
  • 1,401
  • 1
  • 3
  • 14
  • I still seem to be having the issue, but I also just found another. My header text box isn't showing and that's probably where my issue is. Once I figure that out, I'll let you know what happens. – Jakob Glantz Feb 08 '21 at 07:46
  • Yeah, it's still omitting "?page=editnews&" when I hit submit. – Jakob Glantz Feb 08 '21 at 08:08