Hey there, I’m new to PHP and I’m having some problems with an update statement for an application I’m building. When I click on a client to update and then I update their data all of the data in the database for all users changes to the record I just updated. Which is NOT what I want. My code is below. Help would be appreciated!
//Grab requested Client ID for Updating
$clientid=$_GET[‘id’];
$stmt=$db->prepare(“SELECT * FROM clients where id = :id”);
$stmt->bindParam(’:id’, $clientid);
$stmt->execute();
$result = $stmt->fetchall(PDO::FETCH_ASSOC);
//Validate & Filter
if(isset($_POST[‘submit’])){
if(!filter_var($_POST[‘website’], FILTER_VALIDATE_URL))
{
echo “The website you entered is not valid!”;
}else{
$clientid = $_GET[‘id’];
$fname = $_POST[‘fname’];
$lname = $_POST[‘lname’];
$phone = $_POST[‘phone’];
$email = $_POST[‘email’];
$website = $_POST[‘website’];
$stmt=$db->prepare(“UPDATE clients SET fname=’”.$fname."’, lname=’".$lname."’, phone=’".$phone."’, email=’".$email."’, website=’".$website."’");
$stmt->execute();
header(‘Location: client.php’);
die();
}
}