Welcome Guest, Not a member yet? Register   Sign In
Issue with my 'Sign in' script
#6

[eluser]invision[/eluser]
A quick follow-up if it's ok Smile

I have a similar script where I'm letting users comment on my music reviews.

In my Controller, I have:

Code:
function addcomment(){
  
      $this->load->library('form_validation');

      $this->form_validation->set_rules('comment_body', 'Comments', 'trim|required');
  
      if($this->form_validation->run() == FALSE)
      {                
           redirect('review/post/'.$this->input->post('post_id'));
      }
      else
      {  
            $this->MComments->addComment();
          redirect('review/post/'.$this->input->post('post_id'), 'refresh');
      }
  }

Again, if I add text and submit it adds perfectly.
If I don't add text, I don't get an error message Sad It just shows the page again.



Here is my View for reference:

Code:
<?php
echo auto_typography($post['body']);
?>


<h3>Comments</h3>
&lt;?php
if (count($comments)){
    foreach ($comments as $key => $list){
        echo "<p><b>Comment by ".$list['name'].":</b></p>\n";
        echo auto_typography($list['comment_body']);
    }
    echo "<br/>";
}

if (isset($_SESSION['userid'])) {

?&gt;
&lt;?php if(!empty($this->form_validation->_error_array)):?&gt;
    <div class="error">
        &lt;?php echo validation_errors(); ?&gt;  
    </div>  
&lt;?php endif; ?&gt;

<div class="form-container">

  &lt;?php
  echo form_open("review/addcomment");
  ?&gt;
  <fieldset>
    <legend>Add your own comment about &lt;?php echo $post['title']; ?&gt;:</legend>
        
    <div>
    &lt;?php
    echo form_label('Your Comment','comment_body');
    $data = array('name'=>'comment_body','id'=>'comment_body','rows'=>5, 'cols'=>'30');
    echo form_textarea($data);
    ?&gt;      
    </div>
    
    <div class="buttonrow">
    <p>
      &lt;?php
      echo form_hidden('post_id',$post['id']);
      echo form_submit('submit','Add Comment');
      ?&gt;  
    </p>
    </div>        
  </fieldset>
  &lt;?php
  echo form_close();
  ?&gt;

</div>

&lt;?php
} // end session check
else
{

echo '<div class="warning">Please <a href="/index.php/form/signin/" style="background:none">sign in</a> to post a comment for this review</div>';

}
?&gt;

<p>&nbsp;</p>
<p>&nbsp;</p>



Many thanks for any helpers.


Messages In This Thread
Issue with my 'Sign in' script - by El Forum - 10-05-2010, 12:29 PM
Issue with my 'Sign in' script - by El Forum - 10-05-2010, 01:26 PM
Issue with my 'Sign in' script - by El Forum - 10-05-2010, 01:58 PM
Issue with my 'Sign in' script - by El Forum - 10-05-2010, 02:07 PM
Issue with my 'Sign in' script - by El Forum - 10-05-2010, 02:13 PM
Issue with my 'Sign in' script - by El Forum - 10-05-2010, 02:32 PM
Issue with my 'Sign in' script - by El Forum - 10-05-2010, 02:44 PM
Issue with my 'Sign in' script - by El Forum - 10-05-2010, 02:53 PM
Issue with my 'Sign in' script - by El Forum - 10-05-2010, 02:56 PM
Issue with my 'Sign in' script - by El Forum - 10-05-2010, 03:02 PM
Issue with my 'Sign in' script - by El Forum - 10-05-2010, 03:04 PM
Issue with my 'Sign in' script - by El Forum - 10-05-2010, 03:15 PM
Issue with my 'Sign in' script - by El Forum - 10-05-2010, 03:17 PM
Issue with my 'Sign in' script - by El Forum - 10-06-2010, 07:25 AM



Theme © iAndrew 2016 - Forum software by © MyBB