Why does it not update the database??
<?php
ob_start();
session_start();
require_once 'dbconnect.php';
if( !isset($_SESSION['user']) ) {
header("Location: index.php");
exit;
}
$res=mysql_query("SELECT * FROM users WHERE userId=".$_SESSION['user']);
$userRow=mysql_fetch_array($res);
$Nname = $_POST['name'];
$Nemail = $_POST['email'];
$Nlocation = $_POST['location'];
$sql = "UPDATE users SET userName = '$Nname', userEmail = '$Nemail', userLocation = '$Nlocation' WHERE userId=".$_SESSION['user'];
/*if(! $sql ) {
die('Could not update data: ' . mysql_error());
}
echo "Updated data successfully\n";
*/
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Profiel <?php echo $userRow['userName'] ?></title>
<link rel="stylesheet" href="css/style.css" type="text/css" />
<link href="https://fonts.googleapis.com/css?family=Raleway:400, 600" rel="stylesheet">
</head>
<body>
<header>
<h1>Profiel</h1>
</header>
<nav>
<a href="/home.php">Home</a>
<a href="/profile.php">Profiel</a>
<a href="/logout.php?logout">Log uit</a>
</nav>
<div class="content">
<h1>Welkom <?php echo $userRow['userName'] ?></h1>
<?php/* switch (true) {
case isset($_GET['change']):*/?>
<form class="update" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="post">
<table>
<p><tr><td></td><td>Oud</td><td>Nieuw</td></tr></p>
<p><tr><td>Naam: </td><td><?php echo $userRow['userName'] ?></td><td> <input type="text" name="name" value="<?php echo $userRow['userName'] ?>"></td></tr></p>
<p><tr><td>Email: </td><td><?php echo $userRow['userEmail'] ?></td><td><input type="text" name="email" value="<?php echo $userRow['userEmail'] ?>"></td></tr></p>
<p><tr><td>Werk Locatie: </td><td><?php echo $userRow['userLocation'] ?></td><td><input type="text" name="location" value="<?php echo $userRow['userLocation'] ?>"></td></tr></p>
</table>
<button type="submit" name="button">Opslaan</button>
</form>
<?php /*break;
default:?>
<table>
<p><tr><td>Naam: </td><td><?php echo $userRow['userName'] ?></td></tr></p>
<p><tr><td>Email: </td><td><?php echo $userRow['userEmail'] ?></td></tr></p>
<p><tr><td>Werk Locatie: </td><td><?php echo $userRow['userLocation'] ?></td></tr></p>
</table>
<a href="/profile.php?change">veranderen</a>
<?php echo $Nname; ?>
<?php break;
}*/?>
</div>
I dont understand why it is not updating the database, i tried everyting. Thanks for helping. The database connection is good. But i dont know how i send that UPDATE to my database i dont understand that. Could someone say how i need to do it??