forms - Handling specific php POST data -
forms - Handling specific php POST data -
i'm trying create little command panel little blog scheme making. far, have managed pull database how many articles there , details each article. info have created following:
the code looks this:
while ($row = $smcfunc['db_fetch_assoc']($request)) { echo '<form action="" method="post" name="blgform"> <div class="blgdiv"> <div class="leftdiv"> <input type="text" value="'. $row['title'] .'" /> <br> <input type="text" value="'. $row['img'] .'" /> <br> <input type="text" value="'. $row['topic_id'] .'" /> </div> <div class="rightdiv"> <textarea class="desctextarea">'. $row['description'] .'</textarea> </div> <table class="blgtable"> <tr> <td><a href="#">unpublish</a></td> <td style="text-align: center;"><a href="javascript: document.forms[\'blgform\'].submit();" name="blgsubmit">save changes</a></td> <td style="text-align: right;"><a href="#">delete entry</a></td> </tr> </table> </div> </form>'; } i know how delete , edit stuff database, not know how create script run code specific form needs edit/delete.
i know need handle edited form when post'ed it's whole post/retrieve part unsure of.
i read using if(isset($_post... clueless of how that, in case of multiple forms one.
also, how post form without using button? i'd rather have text-link.
add or update
i suggest utilize value of "tropic_id" because single value. when returning form, if form add together value must topic_id empty.
<input type="hidden" name="topic_id" value=""> <!-- add together --> or
<input type="hidden" name="topic_id" value="321"> <!-- update --> if edit, homecoming it.
always value in post topic_id, not empty editing.
you can check this:
// prevent undefined warning defining topic_id var. $topic_id = isset($_post['topic_id']) ? $_post['topic_id'] : ''; // if($topic_id != ''){ //something update }else{ //something add together } send without button
use javascript or jquery:
create link/div/button
<div id="idofyourbutton">send</div> or
<button id="idofyourbutton">send</button> javascript:
<script> document.getelementbyid("idofyourbutton").onclick = function(){ document.getelementbyid("idofyourform").submit(); } </script> jquery:
<script> $(document).ready(function(){ $(document).on('click', '#idofyourbutton', function(){ $("form#idofyourform").submit(); }); }); </script> to utilize jquery need jquery library
php forms post
Comments
Post a Comment