为什么php表单没有提交?

时间:2016-08-22 06:23:34

标签: php html

我正在网站上开发一个在线录入的脚本。以下是页面的php代码。问题是它没有提交。

    <?php
include ("include/header.php"), include ("include/config.php");

 if(isset($_POST['applyAdmission'])) {

  $admission_no = $_POST['admission_no'];
  $f_name = $_POST['f_name'];
  $l_name = $_POST['l_name'];
  $p_add = $_POST['p_add'];
  $c_add = $_POST['c_add'];
  $dob = $_POST['dob'];
  $education = $_POST['education'];
  $mobile = $_POST['mobile_no'];
  $course = $_POST['course'];
  $subjects = $_POST['subjects'];
  $timing = $_POST['timing'];

  $filepath_pic = $_FILES['picture']['name'];
  $res_move_pic = move_uploaded_file($_FILES['picture']['tmp_name'], "/admission/".$filepath_pic);

  $filepath_sign = $_FILES['sign']['name'];
  $res_move_sign = move_uploaded_file($_FILES['sign']['tmp_name'], "/admission/".$filepath_sign);

  $agree_terms = $_POST['agree_terms'];
  $agree_cond = $_POST['agree_cond'];


  if ($res_move_pic == 1 && $res_move_sign == 1 ) {

    $query = "INSERT into online_admission (f_name, l_name, p_add, c_add, dob, degree, mobile_no, course, subjects, timing, pic, sign, agree_terms, agree_cond, applied_on) 
             values ('$f_name','$l_name','$p_add','$c_add','$dob','$education','$mobile','$course','$subjects','$timing','$filepath_pic','$filepath_sign','$agree_terms','$agree_cond','now()')";
    $res = mysql_query($query) or die("ERROR: Unable to insert into database.");

    if ($res == 1) {
      header('Location:http://adarshclasses.in/admission_success.php/');
      exit();
     } else {
      header('Location:http://adarshclasses.in/admission_failed.php/');
      exit();
        }
     } else {
       echo "Error in updateing profile pic and sign";
   }
 } else {
   //echo "Please submit the form, thanks!";
}

;?>

表单中的所有内容都是正确的,就像我在$_POST中使用的表单中添加了相同的名称,但它仍然不起作用,请帮助我解决此问题。

以下是html格式代码:

<form class="form-horizontal" id="admission_form" method="post" action="" enctype="multipart/form-data">

 <!--div class="row">     
  <div class="col-lg-6">

      <label for="admission_no"> Admission No. </label>
      <input type="hidden" class="form-control" name="admission_no" value="<?php echo $admission_no ;?>" readonly disabled>

  </div>
 </div--><br>


 <div class="row">     
  <div class="col-lg-6">

      <label for="f_name"> First Name <span class="required">*</span> </label>
      <input type="text" class="form-control" name="f_name" placeholder="Your first name" value="<?php echo $f_name ;?>" required>

  </div>     
  <div class="col-lg-6">

      <label for="l_name"> Last Name <span class="required">*</span></label>
      <input type="text" class="form-control" name="l_name" placeholder="Your last name" value="<?php echo $l_name ;?>" required>

  </div>
 </div><br>

 <div class="row">
  <div class="col-lg-12">
   <label for="p_add"> Permanent Address <span class="required">*</span></label>
   <textarea class="form-control" name="p_add" placeholder="Please write your permanent address" value="<?php echo $p_add ;?>" required></textarea>
  </div>
 </div><br>


 <div class="row">
  <div class="col-lg-12">
   <label for="c_add"> Current Address in Jodhpur <span class="required">*</span></label>
   <textarea class="form-control" name="c_add" placeholder="Please write your address where you currently living" value="<?php echo $c_add ;?>" required></textarea>
  </div>
 </div><br>  


 <div class="row">     
  <div class="col-lg-6">

      <label for="dob"> Date of birth <span class="required">*</span></label>
      <input type="date" class="form-control" name="dob" placeholder="Your date of birth eg:- 25/11/1996" value="<?php echo $dob ;?>" required>

  </div>     
  <div class="col-lg-6">

      <label for="education"> Recent passed degree/exam - </label>
      <input type="text" class="form-control" name="education" placeholder="for example - BA/ B.Sc etc." value="<?php echo $education ;?>" >

  </div>
 </div><br>

 <div class="row">     
  <div class="col-lg-6">

      <label for="mobile_no"> Mobile Number <span class="required">*</span></label>
      <input type="number" class="form-control" name="mobile_no" placeholder="Enter your mobile number, eg - 8384991980" value="<?php echo $mobile_no ;?>" required>

  </div>     
  <div class="col-lg-6">

      <label for="course"> Select course <span class="required">*</span> </label>

      <select class="form-control" name="course" required>
       <option value="none"> --- Select one course --- </option>
       <option value="IAS"> IAS </option>
       <option value="RAS"> RAS </option>
       <option value="Police constable"> Police constable </option>
       <option value="SI"> SI </option>
       <option value="Railway"> Railway </option>
       <option value="REET"> REET </option>
       <option value="Teacher"> Teacher </option>
       <option value="Patwar"> Patwar </option>
       <option value="Bank PO"> Bank PO </option>
       <option value="Jr Accountant"> Jr Accountant </option>
       <option value="Rajasthan police"> Rajasthan police </option>
       <option value="SSC (10+2)"> SSC (10+2) </option>
      </select>

  </div>
 </div><br>

 <div class="row">     
  <div class="col-lg-6">

      <label for="subjects"> Subjects - </label>
      <input type="text" class="form-control" name="subjects" placeholder="Enter your subject you want to read" value="<?php echo $subjects ;?>" required>

  </div>     
  <div class="col-lg-6">

      <label for="timing"> Classes Timing - </label>
      <input type="text" class="form-control" name="timing" placeholder="Your preferred time for coaching" value="<?php echo $timing ;?>" required>


  </div>
 </div><br>

 <div class="row">     
  <div class="col-lg-6">

      <label for="picture"> Upload your picture <span class="required">*</span></label>
      <input type="file" class="form-control" name="picture" required>

  </div>     
  <div class="col-lg-6">
      <label for="sign"> Upload your signature <span class="required">*</span></label>
      <input type="file" class="form-control" name="sign" required>
  </div>
 </div><br>

<div class="row">
  <div class="col-md-12">
     <input type="checkbox" aria-label="..." name="agree_terms" value="1"> I agree with Rules and Regulations mentioned below.<br>
     <input type="checkbox" aria-label="..." name="agree_cond" value="1"> I hearbly declare that Adarsh Classes can use my pictures after my selection for advertising purpose.
  </div><!-- /.col-lg-6 -->
</div><!-- /.row -->

<div class="row">
 <div class="col-lg-6">
  <div class="form-group">
   <button type="text" name="submit" class="btn btn-success btn-lg btn-block" name="applyAdmission"> Submit my application form </button>
  </div>
 </div>
</div>  



   </form>

6 个答案:

答案 0 :(得分:1)

您正在使用<input type="button"的HTML页面输入类型背后的原因 而不是<input type="submit"。使用有效的<input type="submit"。 示例:

<input type="submit" name="" value="Submit">

答案 1 :(得分:0)

<button>更改为<input>。按钮可以使用javascript,但只有PHP按钮不能使用发布数据。您无法通过POST获取<button>数据。为此,您必须使用<input>

改变这个

<button type="text" name="submit" class="btn btn-success btn-lg btn-block" name="applyAdmission"> Submit my application form </button>

<input type="submit" name="applyAdmission">

第二

以下是语法错误include ("include/header.php"), include ("include/config.php");

PHP要求在每个语句末尾以分号结束指令。请按;而不是,分隔它们。

include ("include/header.php");
include ("include/config.php");

您可以查看documentation了解更多深层信息

答案 2 :(得分:0)

更改

<button type="text">

<button type="submit">

答案 3 :(得分:0)

更改

 button type="text" to type="button" Or input type ="submit/button"

答案 4 :(得分:0)

您需要更改此代码:

<button type="text" name="submit" class="btn btn-success btn-lg btn-block" name="applyAdmission"> Submit my application form </button>

以下代码:

<input type="submit" name="applyAdmission" value="Submit my application form" class="btn btn-success btn-lg btn-block" />

您还需要确保在同一个文件中编写PHP代码,否则必须在下面一行的action标记中添加PHP文件名:

<form class="form-horizontal" id="admission_form" method="post" action="" enctype="multipart/form-data">

您的代码中也有一些PHP错误,因此您必须在PHP代码中添加第一行,然后修复PHP致命错误。

ini_set('display_errors', '1');

答案 5 :(得分:0)

我看到一点语法错误,我认为修复此问题会解决您的问题。

更改

var documentInteractionController: UIDocumentInteractionController!

@IBAction func openDocument(sender: UIButton) {
  let URL: NSURL = NSBundle.mainBundle().URLForResource("yourPDF", withExtension: "pdf")!

    if (URL != "") {
        // Initialize Document Interaction Controller
        self.documentInteractionController = UIDocumentInteractionController(URL: URL)

        // Configure Document Interaction Controller
        self.documentInteractionController.delegate = self

        // Present Open In Menu
        self.documentInteractionController.presentOptionsMenuFromRect(sender.frame, inView: self.view, animated: true)
            //presentOpenInMenuFromRect
    }
}

// UIDocumentInteractionControllerDelegate
func documentInteractionControllerViewControllerForPreview(controller: UIDocumentInteractionController) -> UIViewController {
    return self
}

include ("include/header.php"), include ("include/config.php");

为了向您显示语法错误,以下是一个示例:

include ("include/header.php");
include ("include/config.php");

回应:

<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');

include("test.php"), include("someother.php");

输入类型不正确

您还应该更改按钮类型。

更改

 Parse error: syntax error, unexpected ',' in ...\tests\includeTest.php on line 6

<button type="text"...