Outline of what I'm trying to do: I have a table in my db called agents , one of the columns in the table is called activated
. I want to be able to enter the agents username (row 1 in the agents table) and then have the row within the column for activated
update to a 1 (instead of the default of 0 which identifies the user as not activated)
. I'm clearly going wrong, can someone point out where?? Thank you all for your time.
<?php
error_reporting(E_ALL & ~E_NOTICE);
session_start();
if (isset($_SESSION['id'])){
$userId = $_SESSION['id'];
$username = $_SESSION['username'];
} else {
header('Location: home.php');
die();
}
?>
<?php
if($_POST['submit']){
include_once("connection.php");
$username = strip_tags($_POST['username']);
$sql = "SELECT username, FROM agents WHERE username = '$username'";
$query = mysqli_query($dbCon, $sql);
if ($query) {
$row = mysqli_fetch_row($query);
$dbUsername = $row[1];
}
?>
<?php
$dbUsername = $row[1];
if ($username == $dbUsername){
$sql2 = "UPDATE agents SET activated ='1' WHERE $username = username";
$query2 = mysqli_query($dbCon, $sql2);
header('Location: userstaff.php');
} else {
echo "Problem detected.";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Activate agent</title>
</head>
<body>
<h1> Activate agent </h1>
<form method="post" action="activateagent.php">
<input type="text" placeholder="Username" name="username" />
<input type="submit" name="submit" value="activate" />
</form>
</body>
</html>