1

I have a Codeigniter Form:

<?php
    $attr = array('id'=>'urlSubmit','method'=>'post');
    $urlInputAttr = array('name'=>'urlInput','value'=>'yourdomain.com','maxlength'=>'50','size'=>'25');
    echo form_open('urlSubmission',$attr);
    echo form_input($urlInputAttr);
    echo form_close();
?>

then a controller:

 $this->load->view('support/header', $urlSubmissionMeta); ## Header info 
  $this->load->view('support/toolbar'); #logo
  //
    # Determine whether domain already has been crawled.
    $this->load->model('domaincheckmodel');
        $this->domaincheckmodel->verifyduplicates(); 

    # Then Perform Scan
    $this->load->model('performscanmodel');
        $this->performscanmodel->fetchlinks();

A model, called domaincheckmodel.php:

   function verifyduplicates(){
        #PREPARE DATA
        $postedTLD = $_POST["urlInput"];    // Get unsanitized data
        $sql = "SELECT tld from ClientDomain WHERE tld = ?";
        $endquery = $this->db->query($sql,array($this->db->escape_str($postedTLD))); // Query db

        #CONDITION   - if #rows GT 0, load domain already exists.
        if($endquery->num_rows() > 0){
            $this->load->view('err/domainexists'); ##domain already used
            ## redir to new pagee to .. please login..
        } 

        else{ #number of rows must be 0, insert into db
            $newDomain = "INSERT INTO ClientDomain(tld) VALUES('".$this->db->escape_str($postedTLD)."')";
            $this->db->query($newDomain);

            $this->load->view('success/domainfree');
            ## please register to begin saving history of your scans, without doing so you lose results.
        }

The problem is when I submit the form, the if{} and else{} statements work fine in the model, but the variable $postedTLD is sending a blank value to mysql.

Any thoughts here why this is being sent?

4

2 に答える 2

3
$postedTLD = $_POST["urlInput"]; 

次のようにする必要があります。

$postedTLD = $this->input->post('urlInput');

POST 値にアクセスする方法の詳細については、ドキュメントを参照してください。

于 2013-01-23T01:52:04.453 に答える
0

1行のコードを使用して、すべての投稿データを配列として取得できます。

$postData=$this->input->post(NULL,TRUE);
于 2013-01-23T04:32:33.727 に答える