If anyone could help, I'm not getting an error message and I've tried changing the code around a few times and outputting errors.
The database does not update and i'm getting no error message output on submit, I assume i'm missing something?
<?php
session_start();
include_once 'dbconnect.php';
if (!isset($_SESSION['userSession'])) {
header("Location: index.php");
}
$query = $DBcon->query("SELECT * FROM tbl_users WHERE user_id=".$_SESSION['userSession']);
$userRow=$query->fetch_array();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome - <?php echo $userRow['email']; ?></title>
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="bootstrap/css/bootstrap-theme.min.css" rel="stylesheet" media="screen">
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<?php include_once 'header.php'; ?>
<html>
<head></head>
<body>
<h1>Send Message:</h1>
<form action='message.php' method='POST'>
<table>
<tbody>
<tr>
<td>To: </td><td><input type='text' name='to' /></td>
</tr>
<tr>
<td>From: </td><td><input type='text' name='from' /></td>
</tr>
<tr>
<td>Message: </td><td><input type='text' name='message' /></td>
</tr>
<tr>
<td></td><td><input type='submit' value='Create Task' name='sendMessage' /></td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
<?php
if (isSet($_POST['sendMessage'])) {
if (isSet($_POST['to']) && $_POST['to'] != '' && isSet($_POST['from']) && $_POST['from'] != '' && isSet($_POST['message']) && $_POST['message'] != '') {
$to = $_POST['to'];
$from = $userRow['email'];
$message = $_POST['message'];
$q = "INSERT INTO tbl_messages(id,message,to,from) VALUES('', '$message', '$to', '$from')";
if ($DBcon->query($q)) {
$msg = "<div class='alert alert-success'>
<span class='glyphicon glyphicon-info-sign'></span> Message Sent !
</div>";
}else {
$msg = "<div class='alert alert-danger'>
<span class='glyphicon glyphicon-info-sign'></span> Message not Sent! !
</div>";
}
}
}
$DBcon->close();?>
<?php php include_once 'footer.php'; ?>
</html>