Jump to content

everythingisfree

New Members
  • Posts

    1
  • Joined

  • Last visited

everythingisfree's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, I need some assistance updating a MySQL database from a PHP page to update a users username. I'm using SESSION's to store data (as such: the user ID), and concatenating it into the string for a global use. The data is fetched and displayed into the field as expected: <? if(!$_POST['submit']){ $query = "SELECT * FROM users WHERE id = '" . $_SESSION['id'] . "'"; connectDB(); $result = mysqli_query($_SESSION['db'],$query); closeDB(); $row = mysqli_fetch_array($result); ?> The form looks like: <form method="post" action="<?=$_SERVER['php_self']?>"> <p><label for="username">Username </label><input type="text" name="username" value="<?=$row['username']?>"></p> <button type="submit" name="submit" value="update">Update</button> </form> and the query update string: $query = "UPDATE username WHERE id = '" . $_SESSION['id']; "' SET $username ='" . $username . "'"; followed by an echo that let's the use know it's been successful (probably not the best notification method nut anyway)... With the above code, it will not update, I can edit the name, press update and it passes through, says that it was successful but it did not actually send the data onto the database server. I researched this however everyone's answer does not solve mine, am I not doing something correct?. Any help is much appropriated!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.