Jump to content

field not being entered into database..


insrtsnhere13

Recommended Posts

Hey everyone, little bit of background info.  Trying to make a private messaging system.  I have a form on a profile page that just submits the users id to a sendmessage.php file where the actual script is.  Problem is, the receiver's id is not being placed in the database.. heres the code:

Relevant parts of viewprofile.php:
[code]
<?php $user = $_GET['user']; ?>
<form action="sendmessage.php" method="post">
<input type="hidden" name="receiver" value="<?php echo "$user"; ?>">
<input type="submit" value="Send user a message"></form>
[/code]

sendmessage.php:
[code]
<?php
$receiver = $_POST['receiver'];
//sender would be = $_SESSION['id'];
$sender = "000002";
$date = date("l, F d, Y - h:i A");

if(!isset($_POST['submit']))
{ //form hasnt been submitted
?>
Send a message<br>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Message:<br>
<textarea name="message" cols="40" rows="10"></textarea><br><br>
<input type="submit" name="submit" value="Post"></form>
<?php
}
else
{
    $message = $_POST['message'];
    $message = stripslashes($message);
    include("connect.php");
    $query = "INSERT INTO messages (sender, receiver, message, date) VALUES('$sender', '$receiver',

'$message', '$date')";
    $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
    echo "Your message was sent";
    mysql_close($connection);
}
?>
[/code]

everything is being placed into the database except receiver..
Link to comment
https://forums.phpfreaks.com/topic/30269-field-not-being-entered-into-database/
Share on other sites

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.