开发者

Display results after form has been submitted

When I submit a form with PHP that updates a column in my database, it doesn't display the updated data until after the page has been refreshed.

For example, say I want to delete the word watermelon from the following list: apple, banana, watermelon, peach

I would have a submit button with a select form, where you select which word you want to delete (watermelon), and then press submit to delete it. The code will开发者_开发百科 run a query to delete the word watermelon from the list, but when the page reloads, it is still there. You have to refresh the page to view the actual updated results.

Here is the code I'm using for my HTML form

<form action = '' method = 'POST'></form>


Place your database modifications before your output display in the PHP file. e,g,

show_fruits.php

<?php
  // validate $_REQUEST
  // call database function
?>
<html>
  ....
  <?php /* now query for list of items after DB call above was made */ ?>


I think you should declare the action - in your case that should be the name of the php file you want your form to redirect.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜