Salve, ho il seguente problema. Quando clicco il pulsante share che dovrebbe aggiungere un commento a un post nel mio forumo la console mi restituisce questo: POST http://jaku0260.keaweb.dk//index.php/user/updatecomment
404 Not Found 102ms
Il codice in questione è questo piu il link del sito:
http://jaku0260.keaweb.dk/index.php/user/profile
Per entrare è veder potete usare user [email protected] e pass delfino.
Codice del bottone share:
html:
404 Not Found 102ms
Il codice in questione è questo piu il link del sito:
http://jaku0260.keaweb.dk/index.php/user/profile
Per entrare è veder potete usare user [email protected] e pass delfino.
Codice del bottone share:
PHP:
function updatecomment(){
if($this->session->userdata('userid')){
$this->load->model('forum_model');
$id=$this->input->post('postid');
$userID=$this->session->userdata('userid');
$comment=$this->input->post('comment');
$this->forum_model->insertcomment($userID,$id,$comment);
echo 1;
}
else{
echo 0;
}
}
HTML:
<div class="col-lg-2" style="width:72%;min-width:300px;min-height:300px;border-right:1px solid #ccc;height:auto;margin-left: 15%;
border-left: 1px solid #ccc;">
<div id="profile" class="row" style="background: #fff;
border-radius: 5px;
margin-top: 16px;
width:88%;
margin-left:1%;
min-height: 175px;">
<div style="float:left;width:44%">
<img src="<?php echo base_url();?>assets/user/<?php echo $userdata->profilepic;?>" style="width: 60%;
border-radius: 4px;
margin-top: 5px;
margin-left: 5px;
float: left;">
<span class="personnameclass" style="line-height: 2.1;">
<?php echo $userdata->fullname;?>
</span>
<span style="line-height: 2.1;font-size:15;display:block;">
country : <?php if($userdata->country!=NULL) echo $userdata->country;?>
</span>
<span style="line-height: 2.1;font-size:15;display:block;">
Sex : <?php if($userdata->country!=NULL) {if($userdata->sex=='m')echo 'male';else echo 'female';}?>
</span>
<span style="line-height: 2.1;font-size:15;display:block;">
D.O.B : <?php if($userdata->dob!=NULL)echo $userdata->dob;?>
</span>
</div>
<div style="float:right;margin-right: 6px;<?php if($active=='m')echo 'display:none;';?>" class="footer">
<form method="post" action="<?php echo base_url();?>index.php/user/addfriend">
<input type="text" name="friendstatus" hidden value=<?php if($active!='f') echo $a;else echo $active;?> id="reqhiddenfield">
<input type="text" name="userid" hidden value="<?php echo $userdata->userid;?>">
<button type="submit" class="btn btn-primary " >
<?php if($a=='s')echo 'friend request sent'; else if($a=='r') echo 'accept request';else if($active=='f') echo 'Friend';else echo 'Add as friend';?>
</button>
</form>
</div>
</div>
<div style=" <?php if($active!='m')echo 'display:none;';?>">
<label class="col-sm-3 control-label">Update Status</label>
<div>
<div style="width:100%">
<img src="<?php echo base_url();?>assets/user/<?php echo $profpic;?>" class="userpostprofpic">
<form id="updatepost" enctype="multipart/form-data" method="post" action="<?php echo base_url();?>index.php/user/newpost">
<textarea name="postcomment" class=" form-control posttextarea" rows="3" required></textarea>
<div style=" background: url(<?php echo base_url();?>assets/img/uploadpic.png);top: 10.5%; " class="statusattachmentclass">
<input id="uploadImage" type="file" accept="image/jpeg" name="image" style="filter: alpha(opacity=0);opacity: 0; cursor: pointer;" />
</div>
<img id="uploadPreview" class="previewuploadimg"/>
<div class="sharestatusbuttonclass" style="width: 89%;float:none;">
<button type="submit" class="btn btn-primary " style="float: right;margin-top: 7px;">
Share
</button>
</div>
</form>
</div>
</div><!-- status update-->
</div>
<ul class="statusulclass" style="<?php if($active=='f' || $active=='m')echo 'display:block';else 'display:none;'?>">
<?php if($allposts!=NULL){foreach ($allposts as $post){?>
<li class="form-group pkliclass" ><a>
<img src="<?php echo base_url();?>assets/user/<?php echo $post->profilepic;?>" class="profilepicclass"><span class="personnameclass"><?php echo $post->fullname;?></span></a>
<span class="statusstyle"><pa>
<?php echo $post->posttext;?>
</p></span>
<div class="statusimagediv" style="display:<?php if($post->imageurl!=NULL) echo 'block';else echo 'none';?>">
<img data-toggle="modal" data-target="#myModal" src="<?php echo base_url();?>assets/posts/<?php echo $post->imageurl;?>" class="statusimage">
</div>
<div id="showmodal"><!-- idhr likhna hai k image exists or not by display:none-->
<div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<img src="<?php echo base_url();?>assets/posts/<?php echo $post->imageurl;?>" class="img-responsive">
</div>
</div>
</div>
</div>
</div>
<center>
<div style="border-top: 1px solid #ccc;
width: 46%;
margin-top: 2%;
margin-bottom: 2%;">
</div>
</center>
<!--write a comment-->
<div class="row">
<div class="col-lg-1"></div>
<div class="col-lg-10">
<div class="input-group">
<span class="input-group-btn">
<img src="<?php echo base_url();?>assets/user/<?php echo $profpic;?>" class="commentboxpic">
</span>
<input type="text" class="form-control" id="<?php echo $post->postid;?>" placeholder="share your thoughts about this">
<span class="input-group-btn">
<button class="btn btn-default" onclick="hello(<?php echo $post->postid;?>);" type="button">Share</button>
</span>
</div><!-- /input-group -->
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<!--All comments -->
<div class="form-group" style="margin-top: 15px;">
<ul style="padding: 0px;" id="<?php echo $post->postid.'comment';?>">
<?php if($post->comments!=NULL){ foreach($post->comments as $comment ){?>
<li style="list-style:none;margin-top: 10px;">
<div class="row">
<div class="col-lg-1"></div>
<div class="col-lg-10">
<div class="input-group">
<span class="input-group-btn">
<img src="<?php echo base_url();?>assets/user/<?php echo $comment->profilepic;?>" class="commentboxpic">
</span>
<span><span class="personnameclass"><?php echo $comment->fullname;?></span><span style="padding-left:5px;"> <?php echo $comment->commenttext;?></span></span>
</div><!-- /input-group -->
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
</li>
<!--li comments-->
<?php }}?>
</ul>
</div>
</li>
<?php }}?>
</ul>
</div>
<script type="text/javascript">
function hello(id){
var data=document.getElementById(id).value;
if(data !=""){
var hr = new XMLHttpRequest();
// Create some variables we need to send to our PHP file
var url = "<?php echo base_url()?>/index.php/user/updatecomment";
var vars = "postid="+id+"&comment="+data;
hr.open("POST", url, true);
// Set content type header information for sending url encoded variables in the request
hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
// Access the onreadystatechange event for the XMLHttpRequest object
hr.onreadystatechange = function() {
if(hr.readyState == 4 && hr.status == 200) {
var return_data = hr.responseText;
document.getElementById(id+"comment").innerHTML= "<li style='list-style:none;margin-top: 10px;'><div class='row'><div class='col-lg-1'></div><div class='col-lg-10'><div class='input-group'><span class='input-group-btn'><img src='<?php echo base_url();?>assets/user/<?php echo $profpic;?>' class='commentboxpic'></span><span><span class='personnameclass'>Asad Ullah</span><span style='padding-left:5px;'>"+ data+"</span></span></div><!-- /input-group --></div><!-- /.col-lg-6 --></div><!-- /.row --></li>"+document.getElementById(id+"comment").innerHTML;
document.getElementById(id).value="";
}
}
// Send the data to PHP now... and wait for response to update the status div
hr.send(vars); // Actually execute the request
}
}
</script>
<script type="text/javascript" src="<?php echo base_url();?>/assets/js/jquery.imgareaselect.pack.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>/assets/js/script.js"></script>