Bottone submit mi restituisce errore 404 page not found

Jakub Lemiszewski

Utente Attivo
5 Dic 2013
119
1
0
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:
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:
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;">

&nbsp;&nbsp;&nbsp;country : <?php if($userdata->country!=NULL) echo $userdata->country;?>
</span>

<span  style="line-height: 2.1;font-size:15;display:block;">

&nbsp;&nbsp;&nbsp;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;">

&nbsp;&nbsp;&nbsp;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>
 
a me funziona.

A me no come da screenshot quando premo il pulsante share questo accade:
Screen Shot 2014-04-03 at 16.40.35.jpg
 
La riga 596 è alla fine di questo codice
HTML:
<img data-toggle="modal" data-target="#myModal" src="http://jaku0260.keaweb.dk/assets/posts/" 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="http://jaku0260.keaweb.dk/assets/posts/" 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="http://jaku0260.keaweb.dk/assets/user/1.jpeg" class="commentboxpic">
</span>
<input type="text" class="form-control" id="6" placeholder="share your thoughts about this">
<span class="input-group-btn">
<button class="btn btn-default" onclick="hello(6);" 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="6comment">
</ul>
</div>
</li>
<li class="form-group pkliclass" ><a href="http://jaku0260.keaweb.dk/index.php/user/viewprofile/?userid=1">
<img src="http://jaku0260.keaweb.dk/assets/user/1.jpeg" class="profilepicclass"><span class="personnameclass">Jakub Lemiszewski</span></a>
<span class="statusstyle"><pa>
I'm trying, may be it's working</p></span>
<div class="statusimagediv" style="display:none">
<img data-toggle="modal" data-target="#myModal" src="http://jaku0260.keaweb.dk/assets/posts/" 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="http://jaku0260.keaweb.dk/assets/posts/" 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="http://jaku0260.keaweb.dk/assets/user/1.jpeg" class="commentboxpic">
</span>
<input type="text" class="form-control" id="5" placeholder="share your thoughts about this">
<span class="input-group-btn">
<button class="btn btn-default" onclick="hello(5);" 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="5comment">
</ul>
</div>
</li>
<li class="form-group pkliclass" ><a href="http://jaku0260.keaweb.dk/index.php/user/viewprofile/?userid=1">
<img src="http://jaku0260.keaweb.dk/assets/user/1.jpeg" class="profilepicclass"><span class="personnameclass">Jakub Lemiszewski</span></a>
<span class="statusstyle"><pa>
asada</p></span>
<div class="statusimagediv" style="display:none">
<img data-toggle="modal" data-target="#myModal" src="http://jaku0260.keaweb.dk/assets/posts/" 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="http://jaku0260.keaweb.dk/assets/posts/" 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="http://jaku0260.keaweb.dk/assets/user/1.jpeg" class="commentboxpic">
</span>
<input type="text" class="form-control" id="4" placeholder="share your thoughts about this">
<span class="input-group-btn">
<button class="btn btn-default" onclick="hello(4);" 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="4comment">
</ul>
</div>
</li>
<li class="form-group pkliclass" ><a href="http://jaku0260.keaweb.dk/index.php/user/viewprofile/?userid=1">
<img src="http://jaku0260.keaweb.dk/assets/user/1.jpeg" class="profilepicclass"><span class="personnameclass">Jakub Lemiszewski</span></a>
<span class="statusstyle"><pa>
w</p></span>
<div class="statusimagediv" style="display:none">
<img data-toggle="modal" data-target="#myModal" src="http://jaku0260.keaweb.dk/assets/posts/" 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="http://jaku0260.keaweb.dk/assets/posts/" 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="http://jaku0260.keaweb.dk/assets/user/1.jpeg" class="commentboxpic">
</span>
<input type="text" class="form-control" id="3" placeholder="share your thoughts about this">
<span class="input-group-btn">
<button class="btn btn-default" onclick="hello(3);" 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="3comment">
</ul>
</div>
</li>
<li class="form-group pkliclass" ><a href="http://jaku0260.keaweb.dk/index.php/user/viewprofile/?userid=1">
<img src="http://jaku0260.keaweb.dk/assets/user/1.jpeg" class="profilepicclass"><span class="personnameclass">Jakub Lemiszewski</span></a>
<span class="statusstyle"><pa>
good</p></span>
<div class="statusimagediv" style="display:none">
<img data-toggle="modal" data-target="#myModal" src="http://jaku0260.keaweb.dk/assets/posts/" 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="http://jaku0260.keaweb.dk/assets/posts/" 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="http://jaku0260.keaweb.dk/assets/user/1.jpeg" class="commentboxpic">
</span>
<input type="text" class="form-control" id="2" placeholder="share your thoughts about this">
<span class="input-group-btn">
<button class="btn btn-default" onclick="hello(2);" 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="2comment">
</ul>
</div>
</li>
<li class="form-group pkliclass" ><a href="http://jaku0260.keaweb.dk/index.php/user/viewprofile/?userid=3">
<img src="http://jaku0260.keaweb.dk/assets/user/3.jpg" class="profilepicclass"><span class="personnameclass">Sam Janssen</span></a>
<span class="statusstyle"><pa>
Hello!</p></span>
<div class="statusimagediv" style="display:none">
<img data-toggle="modal" data-target="#myModal" src="http://jaku0260.keaweb.dk/assets/posts/" 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="http://jaku0260.keaweb.dk/assets/posts/" 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="http://jaku0260.keaweb.dk/assets/user/1.jpeg" class="commentboxpic">
</span>
<input type="text" class="form-control" id="1" placeholder="share your thoughts about this">
<span class="input-group-btn">
<button class="btn btn-default" onclick="hello(1);" 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="1comment">
</ul>
</div>
</li>
</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 = "http://jaku0260.keaweb.dk//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='http://jaku0260.keaweb.dk/assets/user/5.jpg' 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="http://jaku0260.keaweb.dk//assets/js/jquery.imgareaselect.pack.js"></script>
<script type="text/javascript" src="http://jaku0260.keaweb.dk//assets/js/script.js"></script>
 
anche i miei inserimenti hanno avuto successo,

mentre non succede nulla (neppure errore) inserendo un commento alla discussione già esistente

ciao
Marino
 
grazie delle risposte. Sto cercando un metodo per fare in modo che i commenti per le discussioni gia esistenti funzionino. Vi chiedo di aiutarmi perfavore che ho tempo fino a Domenica a mezzanotte per consegnarlo. Se avete bisogno di vedere altro codice chiedete, ma perfavore aiutatemi perfavore. Grazie mille.
 
L'errore che ricevo io per chiarezza succede quando premo share in una discussione gia esistente. Quando faccio POST mi da che la pagina non è trovata ma è una funzione che invece esiste che fa in modo che il commento venga aggiunto in tabella commenti per i post gia esistenti...
 
Perfavore se qualcuno a un idea sul perchè questo sistema non funziona me lo dica e urgente!!! ... ome scritto in precedenza posso postare altro codice se questo non è sufficiente..
 

Discussioni simili