Jump to content

$_POST


violinrocker

Recommended Posts

I cant seem to post 'sub'... 'comment' is posted but sub is not... what is wrong with my code?

 

$('.comment_button').live("click",function() 
{

var ID = $(this).attr("id");

var comment= $("#ctextarea"+ID).val();
var sub= $("#csub"+ID).val();
var dataString = 'comment='+ comment + '&msg_id=' + ID + '&sub=' + sub;

if(comment=='')
{
alert("Please Enter Comment Text");
}
else
{
$.ajax({
type: "POST",
url: "extra/comment_ajax.php",
data: dataString,
cache: false,
success: function(html){
$("#commentload"+ID).append(html);
$("#ctextarea"+ID).val('');
$("#ctextarea"+ID).focus();
}
});
}
return false;
});

 

this is my form

<form method=\"post\" action=\"\">

<input type='text' name=\"comment\" class=\"comment\" maxlength=\"200\"  id=\"ctextarea$msg_id\" style=\"float:left;width:400px;padding:1px\" ></input>
<input type='hidden' name=\"sub\" id=\"csub$msg_id\" class=\"comment\" value='$sub'></input>
<input type=\"submit\"  value=\" Comment \"  id=\"$msg_id\" class=\"comment_button small green awesome\" style=\"float:left;padding:2px\"/>
</form>

Link to comment
https://forums.phpfreaks.com/topic/237609-_post/
Share on other sites

i removed </input> but it still doesnt post it.

 

i think i may have something wrong in here

 

var comment= $("#ctextarea"+ID).val();
var sub= $("#csub"+ID).val();
var dataString = 'comment='+ comment + '&msg_id=' + ID + '&sub=' + sub;

 

or here

<input type='hidden' name="sub" id="csub$msg_id" class="comment" value='$sub'>

Link to comment
https://forums.phpfreaks.com/topic/237609-_post/#findComment-1220987
Share on other sites

this is whats on my comment_ajax page (without the included files)

 

if(isSet($_POST['comment']))

{

if($POST['sub']==1){ cominsert($session->username,$POST['comment'],$_POST['msg_id']); }

else{ subcominsert($session->username,$POST['comment'],$_POST['msg_id']);}

 

i tried changing $_POST[msg_id] to $POST['sub'] to see if  the value for sub can be inserted into the database, but it inserts nothing

 

Link to comment
https://forums.phpfreaks.com/topic/237609-_post/#findComment-1221003
Share on other sites

You should be developing and debugging your code on a system with error_reporting set to E_ALL and display_errors set to ON so that all the php detected errors will be reported and displayed. The $POST variables would have produced undefined... error messages that would have helped you to find them.

Link to comment
https://forums.phpfreaks.com/topic/237609-_post/#findComment-1221065
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.