tartou2 Posted November 21, 2010 Share Posted November 21, 2010 Hello mates This is supposed to be a page where users can post there message to the chat table but for some reason i can't make the message inside the textarea to be stored in the database. ANyone can help me to fix the code please <?php include "../includes/common.php"; $user_id=$HTTP_SESSION_VARS['id']; $chat=$_POST['chat']; if($chat==1) { $message=$_POST['message']; mysql_query("INSERT INTO chat (user_id,message) VALUES('".$user_id."','".$message."')") or die(mysql_error()); } require 'header.php'; ?> <br /> <form action="chat.php" method="POST" onSubmit="this.chat.value=1;"> <table border="0" cellspacing="2" cellpadding="1" class="tablefadebg" align="center"> <tr valign="top"> <td>Type Here Your Message You want to Post</td><td><textarea cols="60" rows="7" name="message"></textarea></td> </tr> <tr> <td></td> <td><input type="submit" name="B2" value=" Post " style="border: solid 1px #ffbf00; color:yellow;"></td> <input type="hidden" name="chat"> </tr> </table> </form> Link to comment https://forums.phpfreaks.com/topic/219354-need-help-with-this/ Share on other sites More sharing options...
litebearer Posted November 21, 2010 Share Posted November 21, 2010 as a start, you assigned no value to chat in the form Link to comment https://forums.phpfreaks.com/topic/219354-need-help-with-this/#findComment-1137437 Share on other sites More sharing options...
tartou2 Posted November 21, 2010 Author Share Posted November 21, 2010 yes i did using this onSubmit="this.chat.value=1"; in the form. Look again Link to comment https://forums.phpfreaks.com/topic/219354-need-help-with-this/#findComment-1137440 Share on other sites More sharing options...
tartou2 Posted November 21, 2010 Author Share Posted November 21, 2010 never mind i solved the problem by using array to store data in the database Thanks anyway Link to comment https://forums.phpfreaks.com/topic/219354-need-help-with-this/#findComment-1137441 Share on other sites More sharing options...
revraz Posted November 21, 2010 Share Posted November 21, 2010 Mark as solved please Link to comment https://forums.phpfreaks.com/topic/219354-need-help-with-this/#findComment-1137443 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.