简体   繁体   English

更新MYSQL PHP表单

[英]Updating MYSQL PHP Form

I've searched all over the web but unable to find an awnser for my error, i'm doing a simple update form for php mysql and it's just not updating it. 我已经在网上搜索了所有内容,但找不到我的错误的遮篷,我正在为php mysql做一个简单的更新表格,而只是不更新​​它。

See my code below 请参阅下面的代码

Form: 形成:

<form class="" action="edit_account.php" method="post">
              <input type="text" name="username" placeholder="username" value="<?php echo $r['username']; ?>">
              <input type="text" name="name" placeholder="username" value="<?php echo $r['name']; ?>">
              <input type="text" name="email" placeholder="username" value="<?php echo $r['email']; ?>">
              <input type="text" name="country" placeholder="username" value="<?php echo $r['country']; ?>">
              <input type="submit" value="Edit" name="submit">
            </form>

edit_account.php edit_account.php

session_start();
include("db_config.php");
include("../templates/sitehead.php");
$query = $connect->query("SELECT * FROM `users` WHERE `email` = '". $_SESSION['email'] ."'");
$r = $query->fetch_assoc();
$profile = $connect->query("SELECT * FROM `users.profiles` WHERE `user_id` = '". $r['id'] ."'");
$p = $profile->fetch_assoc();

if(isset($_GET['do']) == "submit") {    
    $username = clean($connect, $_POST['username']);    
    $connect->query("UPDATE `users.profiles` SET `username` = '". $username ."' WHERE `user_id` = '". $r['id'] ."'");
}

$query = $connect->query("SELECT * FROM `users.profiles` WHERE `id` = '". $r['id'] ."'");
$p = $query->fetch_assoc();

You should use the following statement: 您应该使用以下语句:

if(isset($_POST['submit']) &&  $_POST['submit'] == "Edit") {
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM