Hello,
I was wondering if any of you can help me please.
My problem is im trying to get this code to insert the record in to my table it says its been added to the database but when i check its not can anyone see whats wrong please?.
Thanks in advance.PHP Code:<?php $title = "MBAPPZ.com - Create A New Message"; ?>
<?php require("styles/top.php"); ?>
<div id='left'>
<?php
if($username){
echo "Create New Message<br /><br />";
$form = "<form action='create_message.php' method='POST'><table>
<tr>
<td><input type='text' name='sendtouser' size='30' class='textbox'></td>
</tr>
<tr>
<td><input type='text' name='subject' size='30' class='textbox'></td>
</tr>
<tr>
<td><textarea name='content' cols='45' rows='7' class='textbox'></textarea></td>
</tr>
<tr>
<td><input type='submit' name='sendbutton' value='Send Message' class='button'></td>
</tr>
</table></form>";
if ($_POST['sendbutton']){
$sendtouser = $_POST['sendtouser'];
$subject = $_POST['subject'];
$content = $_POST['content'];
if ($sendtouser && $subject && $content){
require('scripts/connect.php');
$query = mysql_query("SELECT * FROM users WHERE username='$sendtouser'");
$numrows = mysql_num_rows($query);
if ($numrows == 1){
$row = mysql_fetch_assoc($query);
$to_user = $row['username'];
$to_id = $row['id'];
$date = date("M d, Y");
$query = mysql_query("SELECT * FROM messages WHERE content='$content' AND to_id='$to_id' AND from_id='$userid' AND date='$date'");
$numrows = mysql_num_rows($query);
if ($numrows == 0){
mysql_query("INSERT INTO messages VALUES ('', '$to_user', '$to_id', '$username', '$userid', '$subject', '$content', '$date')");
echo "Your message has been sent. <a href='inbox.php'>Click Here</a> to return to your inbox.";
}
else
echo "You can not resend the same message again. $form";
}
else
echo "The username you have entered is invalid please try again. $form";
}
else
echo "You did not fill the entire message form. $form";
}
else
echo "$form";
}
else
echo "You must be logged in to view this page sorry.";
?>
</div>
<div id='right'>
Advertisements Coming Soon.
</div>
<?php require("styles/bottom.php"); ?>




Reply With Quote