insrtsnhere13 Posted December 11, 2006 Share Posted December 11, 2006 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 More sharing options...
.josh Posted December 11, 2006 Share Posted December 11, 2006 echoing $receiver or $query shows what it should have? Link to comment https://forums.phpfreaks.com/topic/30269-field-not-being-entered-into-database/#findComment-139244 Share on other sites More sharing options...
insrtsnhere13 Posted December 11, 2006 Author Share Posted December 11, 2006 Oh, sorry, i did a little more troubleshooting and found out what the problem was..it didnt like echoing the $receiver variable after hitting post.. so i just made another hidden field with that variable in it.. thanks! Link to comment https://forums.phpfreaks.com/topic/30269-field-not-being-entered-into-database/#findComment-139246 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.