Im just looking to establish the reason all the desired values from my code are not being posted to my database as intended, the only values posted seem to be $msgto, $msgsubject and $msg:
New_message.php
Code: Select all
<?php
session_start();
include('design/header.php');
require('connect.php');
$user=$_SESSION['username'];
$msgfrom=$_GET[$id];
?>
<form name="message" action="messageck.php"
method="post">
To: <br>
<input type="text" name="msgto"><br>
Title: <br>
<input type="text" name="msgsubject"><br>
Message: <br>
<textarea rows="10" cols="60" name="msg">
</textarea><br>
<input type="submit" value="Submit">
<?php
echo '<input type="hidden" name="msgfrom" value="'.$user.'"><br>';
include("design/footer.php");
?>
</form>Code: Select all
<?php
session_start();
include('design/header.php');
require('connect.php');
$msgsubject=$_POST['msgsubject'];
$msgto=$_POST['msgto'];
$msg=$_POST['msg'];
$msgfrom=$_POST['msgfrom'];
$msgdate=$_POST['msgdate'];
$userid=$_POST['id'];
$ck_reciever = "SELECT username FROM users WHERE username = '".$msgto."'";
if( mysql_num_rows( mysql_query( $ck_reciever ) ) == 0 ){
die("The user you are trying to contact does not exist. Please go back and try again.<br>
<form name=\"back\" action=\"new_message.php\"
method=\"post\">
<input type=\"submit\" value=\"Try Again\">
</form>
");
}
elseif(strlen($msg) < 1){
die("Your can't send an empty message!<br>
<form name=\"back\" action=\"new_message.php\"
method=\"post\">
<input type=\"submit\" value=\"Try Again\">
</form>
");
}
elseif(strlen($msgsubject) < 1){
die("You must have a Title!<br>
<form name=\"back\" action=\"new_message.php\"
method=\"post\">
<input type=\"submit\" value=\"Try Again\">
</form>
");
}else{
mysql_query("INSERT INTO users (msgfrom, msgto, msgsubject, msg, msgdate, userid) VALUES ('$msgfrom','$msgto','$msgsubject','$msg','$date','$id')") OR die("Could not send the message: <br>".mysql_error());
echo "The Message Was Successfully Sent!";
echo $msgsubject;
echo $msgto;
echo $msgfrom;
echo $msg;
echo $msgdate;
echo $userid;
?>
<form name="back" action="inbox.php"
method="post">
<input type="submit" value="Back to The Inbox">
</form>
<?php
}
include("design/footer.php");
?>