Ovidiu G Ovidiu G - 4 months ago 8x
SQL Question

Can't update fields from db

I'm trying to update some fileds in the database using a form and for some reason it just refreshes the page without doing anything. Here's the code I used:


$id = $_GET["id"];
$select = "SELECT * FROM blog_members WHERE memberID = '$id'";
$result = mysqli_query($link, $select);
$password = $row['password'];
$email = $row['email'];

<form id="form" action="#" method="post">
<br><table cellspacing='0' cellpadding='0'>
<td><input name="username" type="text" id="username" placeholder="<?php echo $username; ?>" size="25" /></td></tr>
<td><input name="password" type="text" id="password" placeholder="<?php echo $password; ?>" size="25" /></td></tr>
<td><input name="email" type="text" id="email" placeholder="<?php echo $email; ?>" size="25" /></td></tr>
<input type="submit" name="Edit" value="Save" />


$username2 = $_POST['username'];
$password2 = $_POST['password'];
$email2 = $_POST['email'];

$edit = mysqli_query($link, "UPDATE blog_members SET username='$username2',password='$password2',email='$email2' WHERE memberID='$id2'");
$result1 = mysqli_query($link,$edit);

echo mysqli_error($link);
echo "Changes have been saved successfully!";
echo "<meta http-equiv=\"refresh\" content=\"2;URL=view-users.php\">";


I think the query $edit it's not working properly since the page just gets refreshed and the fields from the databse are not updated. I feel like I'm missing something. Any suggestions?


Also change below code


with this, $_POST is right syntax not $POST