Search code examples
phpforum

Action of forum doesn't get ID


I have this set in top of page

if (isset($_GET["edit"]) and !empty($_GET["edit"])) {
   $edit_id=(int)$_GET["edit"];
   $edit_id=sanitize($edit_id);
}

and then i do this with my action on the topbar it shows the number of id but if i do ""view source" i see this:

enter image description here

<form class="form" action="categories.php<?=((isset($_GET['edit']))?'?edit=.$edit_id':'');?>" method="post">

Why is it not getting the id?


Solution

  • because you are setting it as a literal string. try

    action="categories.php<?php echo (isset($_GET['edit'])) ? '?edit='.$edit_id :'');?>"