开发者

Update Statement using Request Method Post

开发者 https://www.devze.com 2023-02-26 05:07 出处:网络
I\'ve done a search related to \'update statement using form\'. Lots of post showed an update function using a form using isset

I've done a search related to 'update statement using form'.

Lots of post showed an update function using a form using isset

if(isset($_POST["submit"])) 开发者_如何学运维{ //process } else { //show form }

Does this mean that it is not possible to do update using this?

if($_SERVER["REQUEST_METHOD"] == "POST") { //process } else { //show form }

It seems so cause my update function doesn't work.

Solved : It works now. I added

<input type="hidden" name="contact_id" value="<?php echo $row["contact_id"]; ?>" />

before

<input type="submit" name="submit" value="Submit" />

in the form

<form method="post" action="update.php">
Username: <input type="text" name="contact_name" value="<?php echo $row["contact_name"]; ?>" />
Email: <input type="text" name="contact_number" value="<?php echo $row["contact_number"]; ?>" />
<input type="hidden" name="contact_id" value="<?php echo $row["contact_id"]; ?>" />
<input type="submit" name="submit" value="Submit" />
</form>


bith ways should work.

But what you should do first is :

var_dump($_POST);

to make sure there is anything in the $_POST var before you do the 1st option.


I don't know if REQUEST_METHOD is always in uppercase. To test this, use strtoupper($_SERVER['REQUEST_METHOD']) == 'POST' and see if it works.

0

精彩评论

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