English 中文(简体)
伪造表格——无效不可行......(对我来说)
原标题:codeigniter form_validation is not working...(for me)

Ok, I m 试图以密码身份验证表格

as a first step I want to make all fields in my form required to make an entry... but I can t make it work

这部法律是:

myBlog.php

    <?php

    class MyBlog extends Controller{


       function MyBlog(){
           parent::Controller();
           $this->load->helper( url ); //here we load a url class that we use later
           $this->load->helper( form );// here we load form class


           $this->load->scaffolding( entries );  //scaffolfing is a feature that lets you add or remove elements from the database



            $this->load->library( form_validation );//load validation class used to validate our forms...
       }

      function index(){

          $data[ title ] = "My Blog Title"; //the title of my blog
          $data[ query ] = $this->db->get( entries ); //here we make a small query to entries table


          $this->load->view( myBlog_view , $data); ///load all data variables on myBlog_view.php
         //this is also for the form validation


            $this->form_validation->set_rules( title ,  Title ,  required );
            $this->form_validation->set_rules( body ,  Body ,  required );
            $this->form_validation->set_rules( author ,  Author ,  required );





          if ($this->form_validation->run() == FALSE)
            {
                //$this->load->view( myBlog_view );
            }
            else
            {
                $this->load->view( formSuccess_view );
            }

 }






     function myBlog_insert(){

           $this->db->insert( entries , $_POST);

           redirect( myBlog/ );
           }


    } 

    ?>

另见我的Blog_view.php档案:

<html>
<head>

<title><?php echo $title; ?></title>
</head>
<body>




<?php foreach($query->result() as $row): ?>
 <div class= curvebox >
<h3><?=$row->title?></h3>


<p class="bodyText"><?=$row->body?></p>
<div class="author"><?="by: ".$row->author." on ".date("D d M Y h:i:s A", strtotime($row->date_time))?></div>
<p class="comments"><?=anchor( myBlog/comments/ .$row->id,  Comments );?></p>
</div>


<?php endforeach; ?>



<div class="theForm">

<?php echo $this->form_validation->error_string; ?>

<?=form_open( myBlog/myBlog_insert );?>


<label for="title">Title:</label>

<input type= text  name="title" size="40" id="title" />
<p>
<label for="body">Body:</label>
<textarea name="body" rows = "10" cols="60" id="body"></textarea>
</p>
<p>
<label for="author">Author:</label>
<input type="text" name="author" size="40" id="author"/>
</p>
<p><input type="submit" value="Submit New Post"/></p>
</form>
</div>
</body>
</html>

除以半填充的形式接受条目外,所有物品都行了。

sorry for the long code.... any help would be appreciated

最佳回答

你希望自己担任你们的职位。 现在,它正在绕过验证。

All of your validation functions are in the index method. Change this line in myBlog_view.php:

<?=form_open(我的Blog/myBlog_insert );?>

:

<?=form_open(我的Blog );?>

然后,在鉴定后,如在你的控制人中,需要把这一方法称作:$this->load->view(表格Success_view );

在这方面,你需要补充:

$this->myBlog_insert();

如果有的话,请见。

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签