Jump to content

[SOLVED] Parse error: parse error in C:\xampp\htdocs\messages.php on line 71


Danny620

Recommended Posts

<?php # Script 11.13 - loggedin.php #3

// The user is redirected here from login.php.

session_start(); // Start the session.

// If no session value is present, redirect the user:
// Also validate the HTTP_USER_AGENT!


$page_title = 'Logged In!';
include ($_SERVER['DOCUMENT_ROOT'].'/includes/header.html');

if(isset($_SESSION['agent'])){
// Print a customized message:
echo "<h1>Logged In!</h1>
<p>You are now logged in, {$_SESSION['first_name']}!</p>
<p><a href=\"logout.php\">Logout</a></p>";
}else{
	echo'
	<h1>Login</h1>
		<form action="login.php" method="post">
		<p>Email Address: <input type="text" name="email" size="20" maxlength="80" /> </p>
		<p>Password: <input type="password" name="pass" size="20" maxlength="20" /></p>
		<p><input type="submit" name="submit" value="Login" /></p>
		<input type="hidden" name="submitted" value="TRUE" />
		</form>';
}

if(isset($_POST['sent'])){
// Trim all the incoming data:
$trimmed = array_map('trim', $_POST);

// Assume invalid values:
$m = FALSE;

// Check for a first name:
if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['message'])) {
	$m = mysqli_real_escape_string ($dbc, $trimmed['message']);
} else {
	echo '<p class="error">You forgot to enter a message!</p>';
}

if ($m) {

$from = $_SESSION['user_id'];

$q = "INSERT INTO messages (to_user, from_user, message) VALUES ('4','$from','$m')";
    $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc));

if (mysqli_affected_rows($dbc) == 1) {
echo 'you message was succsufuly saved';
exit(); }

}

?>
<form id="form1" name="form1" method="post" action="">
  <label>
  <textarea name="message" cols="45" rows="5" id="message">Message Here
</textarea>
  </label>
  <p>
    <label>
    <input type="submit" name="message_send" id="message_send" value="Send" />
    </label>
    <input name="sent" type="hidden" id="sent" value="true" />
  </p>
</form>
<?php include ($_SERVER['DOCUMENT_ROOT'].'/includes/footer.html');
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.