自定义查询在Drupal 7中不起作用

时间:2013-07-01 07:59:49

标签: drupal-7

我在php页面中使用自定义查询,该页面存储在根文件夹 project / check.php 中。我在check.php中编写了Insert查询,但它无效。

我的代码是这样的:

<?php 
    if(isset($_POST['Submit'])) {
    echo 'hel';
    $ipaddress = $_SERVER['REMOTE_ADDR'];
    $name               = isset($_POST['fullname'])?$_POST['fullname']:"";
    $dob                = isset($_POST['datepicker'])?$_POST['datepicker']:"";
    $nationality        = isset($_POST['nationality'])?$_POST['nationality']:"";
    $address            = isset($_POST['address'])?$_POST['address']:"";
    $city               = isset($_POST['city'])?$_POST['city']:"";
    $state              = isset($_POST['state'])?$_POST['state']:"";
    $pincode            = isset($_POST['pincode'])?$_POST['pincode']:"";
    $phone              = isset($_POST['telephone'])?$_POST['telephone']:"";
    $email              = isset($_POST['email'])?$_POST['email']:"";
    $mobile             = isset($_POST['mobileno'])?$_POST['mobileno']:"";
    $weight             = isset($_POST['weight'])?$_POST['weight']:"";
    $height             = isset($_POST['height'])?$_POST['height']:"";
    $marital            = isset($_POST['marital'])?$_POST['marital']:"";
    $degree             = isset($_POST['board'])?$_POST['board']:"";
    $institute          = isset($_POST['institute'])?$_POST['institute']:"";
    $special            = isset($_POST['specialization'])?$_POST['specialization']:"";
    $yearofpaas         = isset($_POST['passingyear'])?$_POST['passingyear']:"";
    $grade              = isset($_POST['grade'])?$_POST['grade']:"";
    $emplyment_history  = isset($_POST['experience'])?$_POST['experience']:"";
    $merits             = isset($_POST['remarks'])?$_POST['remarks']:"";
    $major_achivements  = isset($_POST['achivements'])?$_POST['achivements']:"";
    $interview_attended = isset($_POST['intrview_attended'])?$_POST['intrview_attended']:"";
    $details            = isset($_POST['details'])?$_POST['details']:"";
    $minctc_position    = isset($_POST['ctc_positions'])?$_POST['ctc_positions']:""; 

    if(isset($_POST['declaration'])){
        $declaration = 1;
    } else {
        $declaration = 0;
    }
    if(isset($_FILES) && !empty($_FILES) && $_FILES['cv_file']['name']!=''){

        $file = explode('.',trim($_FILES['cv_file']['name']));
        if($file[1]=='pdf' || $file[1]=='doc' || $file[1]=='docx') {
            $cv_file = $file[0]."_".rand(11111111111,99999999999).".".$file[1];
            $_FILES['cv_file']['name'] = $cv_file;
            move_uploaded_file($_FILES['cv_file']['tmp_name'],'uploads/'.$_FILES['cv_file']['name']);
        } else {
            $err_message = 'File must be pdf,doc or docx type.';
        }

    } else {
        $cv_file = '';
    }
    $dataField = array('datetime'=>date(),
                        'ipadress' => $ipaddress, 
                        'name' => $name,
                        'dob' => $dob, 
                        'nationality' => $nationality, 
                        'address' => $address, 
                        'city' => $city, 
                        'state' => $state, 
                        'pincode' => $pincode,
                        'phone' => $phone,
                        'email' => $email,
                        'mobile' => $mobile,
                        'weight' => $weight,
                        'height'=> $height,
                        'marital' => $marital,
                        'degree' => $degree,
                        'institute' => $institute,
                        'special' => $special,
                        'yearofpaas' => $yearofpaas,
                        'grade' => $grade,
                        'emplyment_history' => $emplyment_history,
                        'merits'    => $merits,
                        'major_achivements' => $major_achivements,
                        'interview_attended' => $interview_attended,
                        'details' => $details,
                        'minctc_position' => $minctc_position,
                        'cv_file' => $cv_file,
                        'declaration' => $declaration); 

    echo $id = db_insert('tbl_users')->fields($dataField)->execute();

}       

?>

此插入查询无效。我正在使用Drupal 7。 先谢谢!

0 个答案:

没有答案