Jump to content

Simple messaging form-Blank page on submit


kirkh34

Recommended Posts

<?php
session_start();
include_once "scripts/connect_to_mysql.php";
$from_user= $_SESSION['id'];
$to_user= $_GET['id'];

$sql = mysql_query("SELECT * FROM myMembers WHERE id='$to_user'");
while($row = mysql_fetch_array($sql)){ 

$firstname = $row["firstname"];
}

?>


<!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>Message to <?php echo "$firstname"; ?></title>




<form name="message" action="messageck.php" method="post">
Title: <input type="text" name="message_title"><br>
Message:<br /> <textarea rows="20" cols="50" name="message_content"></textarea>
<?php
echo '<input type="hidden" name="to_user" value="'.$to_user.'"><br>';
?>
<?php
echo '<input type="hidden" name="from_user" value="'.$from_user.'"><br>';
?>
<input type="submit" value="Submit">
</form>



</body>
</html>

<?php
session_start();
$message_title= $_POST['message_title'];
$message_content= $_POST['message_content'];
$to_user= $_POST['to_user'];
$from_user= $_POST['from_user'];

if (isset ($_POST['message_title'])){

include_once "scripts/connect_to_mysql.php";

if((!$message_title) || (!$message_content)){  

if(!$message_title){  
$msgToUser = "You need a title!";	
include_once "msgToUser.php";

}  

if(!$message_content){  
$msgToUser = "You need a body!";	
include_once "msgToUser.php";

}
}
}

else {

$sql = mysql_query("INSERT INTO messages (to_user, from_user, message_content, message_title) 
     VALUES('$to_user','$from_user','$message_content','$message_title')")  
or die (mysql_error()); 

$msgToUser = "Your message has been sent";	
include_once "msgToUser.php";	

}


?>

 

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.