- Messages
- 18
- Reaction score
- 0
- Points
- 16
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
<?php include "db.php" ?>
<?php include "functions.php" ?>
<?php
if(isset($_POST['submit'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$id = $_POST['id'];
$query = "UPDATE users SET ";
$query .= "username = '$username', ";
$query .= "password = '$password' ";
$query .= "WHERE id = $id";
$result = mysqli_query($connection, $query);
if(!$result) {
die(mysqli_error($connection));
}
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>update</title>
<body>
<form action="update.php" method="post">
<div>
<label for="username">Username: </label>
<input type="text" name="username" placeholder="Enter Username">
</div>
<div>
<label for="password">Password: </label>
<input type="password" name="password" placeholder="Enter Password">
</div>
<div>
<select name="id" id="id">
<?php displayResult(); ?>
</select>
</div>
<input type="submit" name="submit" value="Update">
</form>
</body>
</head>
</html>
=================================
yan po yung lahat nung codes na try ko na po yung ibang solution pero ayaw parin pong gumana patulong naman po mga ka symbs salamat
<?php include "db.php" ?>
<?php include "functions.php" ?>
<?php
if(isset($_POST['submit'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$id = $_POST['id'];
$query = "UPDATE users SET ";
$query .= "username = '$username', ";
$query .= "password = '$password' ";
$query .= "WHERE id = $id";
$result = mysqli_query($connection, $query);
if(!$result) {
die(mysqli_error($connection));
}
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>update</title>
<body>
<form action="update.php" method="post">
<div>
<label for="username">Username: </label>
<input type="text" name="username" placeholder="Enter Username">
</div>
<div>
<label for="password">Password: </label>
<input type="password" name="password" placeholder="Enter Password">
</div>
<div>
<select name="id" id="id">
<?php displayResult(); ?>
</select>
</div>
<input type="submit" name="submit" value="Update">
</form>
</body>
</head>
</html>
=================================
yan po yung lahat nung codes na try ko na po yung ibang solution pero ayaw parin pong gumana patulong naman po mga ka symbs salamat