Jump to content

PHP Won't Display


Stalingrad

Recommended Posts

Hello. I've programmed a very simple Personal Messaging System for my website, and it works fine, except when you go to view the actual message, it won't display it, it displays blank. I've included my code below. Any help is appreciated, thank you in adcance! =]

 

inbox.php:

<?php
session_start();
include("config.php");
if($_SESSION['username'] == "" || $_SESSION['password'] == "") {
notloggedin();
}
if($_SESSION['username'] != "" && $_SESSION['password'] != "") {
start();
$title = "<font size=6>Inbox</font>";
$action = $_GET['action'];
if($action != "compose" && $action != "view" && $action != "delete" && $action != "reply") {
echo "$title<br><br><a href=?action=compose>Compose</a><br><br><table border=\"1\" bordercolor=\"black\" cellpadding=\"10\" cellspacing=\"0\" height=\"24px\" width=\"100%\"><tr><td><b><center>From</center></b></td><td><b><center>Subject</center></b></td><td><center><b>Status</b></center></td></tr>";
$messages = mysql_query("SELECT * FROM messages WHERE userto='$username' ORDER BY id ASC");
while($inbox = @mysql_fetch_array($messages)) {
$message_id = mysql_query("SELECT id FROM messages WHERE subject='$showsubject'");
$mid = $inbox['id'];
$meid = $_GET['id'];
$showfrom = $inbox['userfrom'];
$showsubject = $inbox['subject'];
$showstatus = $inbox['status'];
echo "<tr><td><center><a href=search.php?username=$showfrom>$showfrom</center></td><td><center><a href=inbox.php?action=view&id=$mid>$showsubject</a></center></td><td><center>$showstatus</center></td></tr>";
}
echo "</table>";
}

if($action == "compose") {
$ssubject = $_POST['subject'];
$userto = $_POST['userto'];
$sbody = $_POST['body'];
$send = $_POST['send'];
$datenow = date('l, F jS, Y');
if(!isset($send)) {
echo "<font size=6>Compose</font><br><br><a href=?action=compose>Compose</a><br><br><table border=\"1\" bordercolor=\"black\" cellpadding=\"5\" cellspacing=\"0\" height=\"100%\" width=\"440px\"><tr><td>"; ?><html><form action="<?php echo "$PHP_SELF"; ?>" method="POST">Subject: <input type="text" name="subject">    To: <input type="text" name="userto"></td></tr><tr><td><textarea name="body" cols="50" rows="14"></textarea></td></tr></table><br><br><input type="submit" name="send" value="Send Message"></form></html><?php
}
if(isset($send)) {
if($ssubject == "" || $userto == "" || $sbody == "" ) {
echo "<font size=6>Inbox - Compose</font><br><br><a href=?action=compose>Compose</a><br><br><font color=red>Error! Please Fill out the Entire Form.</font><br><br><table border=\"1\" bordercolor=\"black\" cellpadding=\"5\" cellspacing=\"0\" height=\"100%\" width=\"440px\"><tr><td>"; ?><html><form action="<?php echo "$PHP_SELF"; ?>" method="POST">Subject: <input type="text" name="subject">    To: <input type="text" name="to"></td></tr><tr><td><textarea name="body" cols="50" rows="14"></textarea></td></tr></table><br><br><input type="submit" name="send" value="Send Message"></form></html><?php
}

$checkto = mysql_num_rows(mysql_query("SELECT id FROM users WHERE username='$userto'"));
if($checkto == "0") {
echo "<font size=6>Inbox - Compose</font><br><br><a href=?action=compose>Compose</a><br><br><font color=red>Error! That User doesn't Exist.</font><br><br><table border=\"1\" bordercolor=\"black\" cellpadding=\"5\" cellspacing=\"0\" height=\"100%\" width=\"440px\"><tr><td>"; ?><html><form action="<?php echo "$PHP_SELF"; ?>" method="POST">Subject: <input type="text" name="subject">    To: <input type="text" name="userto"></td></tr><tr><td><textarea name="body" cols="50" rows="14"></textarea></td></tr></table><br><br><input type="submit" name="send" value="Send Message"></form></html><?php
}

if($ssubject != "" && $userto != "" && $checkto >= "1" && $sbody != "") {
mysql_query("INSERT INTO messages (userto, userfrom, subject, body, datesent, status) VALUES ('$userto', '$username', '$ssubject', '$sbody', '$datenow', 'Unread')") or die(mysql_error());
echo "<font size=6>Inbox - Compose</font><br><br><a href=inbox.php>Inbox</a> | <a href=?action=compose>Compose</a><br><br><font color=green>Success! Your Message has been Sent.</font><br>";
}
}
if($action == "view") {
$messages_query = mysql_query("SELECT * FROM messages WHERE id='$_GET[id]'");
while($showit = mysql_fetch_array($messages_query)) {
$user_from = $showit['userfrom'];
$subject_is = $showit['subject'];
$body_is = $showit['body'];
}

echo "<font size=6>Inbox - View</font><br><br><a href=?action=compose>Compose</a> | <a href=inbox.php>Inbox</a><br><br><table border=\"1\" bordercolor=\"black\" height=\"100%\" width=\"440px\" cellpadding=\"5\" cellspacing=\"0\"><tr><td>Subject: $subject_is         From: $user_from</td></tr><tr><td>$body_is</td></tr></table><br>";
}
stop();
}
}
?>

Link to comment
Share on other sites

a page showing up blank is often a sign of a parse error, but php is being tight-lipped about the whole affair.  try putting these lines at the top:

 

ini_set('display_errors', 'On');
error_reporting(E_ALL);

 

and see what comes back.

Link to comment
Share on other sites

your brackets are off. indent your code and you'll see how that IF is inside another IF. if the one on the outside is TRUE, then the other one is automatically FALSE. i indented part of your code to find the problem:

 

if($action == "compose") {
$ssubject = $_POST['subject'];
$userto = $_POST['userto'];
$sbody = $_POST['body'];
$send = $_POST['send'];
$datenow = date('l, F jS, Y');
if(!isset($send)) {
	echo "<font size=6>Compose</font><br><br><a href=?action=compose>Compose</a><br><br><table border=\"1\" bordercolor=\"black\" cellpadding=\"5\" cellspacing=\"0\" height=\"100%\" width=\"440px\"><tr><td>"; ?><html><form action="<?php echo "$PHP_SELF"; ?>" method="POST">Subject: <input type="text" name="subject">    To: <input type="text" name="userto"></td></tr><tr><td><textarea name="body" cols="50" rows="14"></textarea></td></tr></table><br><br><input type="submit" name="send" value="Send Message"></form></html><?php
}
if(isset($send)) {
	if($ssubject == "" || $userto == "" || $sbody == "" ) {
		echo "<font size=6>Inbox - Compose</font><br><br><a href=?action=compose>Compose</a><br><br><font color=red>Error! Please Fill out the Entire Form.</font><br><br><table border=\"1\" bordercolor=\"black\" cellpadding=\"5\" cellspacing=\"0\" height=\"100%\" width=\"440px\"><tr><td>"; ?><html><form action="<?php echo "$PHP_SELF"; ?>" method="POST">Subject: <input type="text" name="subject">    To: <input type="text" name="to"></td></tr><tr><td><textarea name="body" cols="50" rows="14"></textarea></td></tr></table><br><br><input type="submit" name="send" value="Send Message"></form></html><?php
	}

	$checkto = mysql_num_rows(mysql_query("SELECT id FROM users WHERE username='$userto'"));
	if($checkto == "0") {
		echo "<font size=6>Inbox - Compose</font><br><br><a href=?action=compose>Compose</a><br><br><font color=red>Error! That User doesn't Exist.</font><br><br><table border=\"1\" bordercolor=\"black\" cellpadding=\"5\" cellspacing=\"0\" height=\"100%\" width=\"440px\"><tr><td>"; ?><html><form action="<?php echo "$PHP_SELF"; ?>" method="POST">Subject: <input type="text" name="subject">    To: <input type="text" name="userto"></td></tr><tr><td><textarea name="body" cols="50" rows="14"></textarea></td></tr></table><br><br><input type="submit" name="send" value="Send Message"></form></html><?php
	}

	if($ssubject != "" && $userto != "" && $checkto >= "1" && $sbody != "") {
		mysql_query("INSERT INTO messages (userto, userfrom, subject, body, datesent, status) VALUES ('$userto', '$username', '$ssubject', '$sbody', '$datenow', 'Unread')") or die(mysql_error());
		echo "<font size=6>Inbox - Compose</font><br><br><a href=inbox.php>Inbox</a> | <a href=?action=compose>Compose</a><br><br><font color=green>Success! Your Message has been Sent.</font><br>";
	}
}

if($action == "view") { // WON'T HAPPEN HERE. AT THIS POINT, WE ALREADY KNOW THAT $action == "compose"

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.