简体   繁体   中英

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.

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

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") {
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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