缺少$ _POST变量中的值

时间:2015-10-24 11:40:10

标签: php html

我有一个包含大约65个输入字段的HTML表单。该表单使用POST方法,并在提交时将字段定向到用于数据库输入的PHP脚本。没有科学。

但是,很少有POST个变量生成undefined index警告,并且在相应的数据库列中具有空值。我似乎无法弄清楚为什么很少有变量产生未定义的索引警告而其余的工作正常。

例如,以下是使用POST变量检索值的htmlphp脚本。 cfrom生成undefined index警告,cjnb工作正常。 HTML:

      <div class="col-5">
    <label>
      Current Job Nature of Business
      <input placeholder="" id="cjnb" name="cjnb" tabindex="27">
    </label>
  </div>
    <div class="col-5">
    <label>
      Joining Date
      <input placeholder="YYYY-MM-DD" id="cfrom" name="cfrom" tabindex="28" >
    </label>
  </div>

PHP:

$cjnb=$_POST['cjnb'];
$cfrom=$_POST['cfrom'];

我尝试使用isset并将变量设置为空值可能是因为它在$_POST['cfrom']中找不到值,但是,我在cfrom输入值中输入了值

请帮助!

更新:完整表格

<!doctype html>
<html lang="en-US">
<head>
  <meta charset="utf-8">
  <meta http-equiv="Content-Type" content="text/html">
  <title>Horizontal Application Form - Template Monster Demo</title>
  <meta name="author" content="Jake Rocheleau">


  <link rel="shortcut icon" href="http://static.tmimgcdn.com/img/favicon.ico">
  <link rel="icon" href="http://static.tmimgcdn.com/img/favicon.ico">
  <link rel="stylesheet" type="text/css" media="all" href="css/styles.css">
  <link rel="stylesheet" type="text/css" media="all" href="css/switchery.min.css">
  <script type="text/javascript" src="js/switchery.min.js"></script>





</head>

<body>
  <div id="wrapper">


    <h1>dfsdfsdf</h1>
    <h2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|sdfdfs</h2>

 <!-- <form onsubmit="return false">-->
  <form action="save.php" method="POST" enctype="multipart/form-data">

  <div class="col-1" style="height:30px;">
  </div>
  <div class="col-1" style="background-color:#f4f4f3;">
<label>Position of Interest</label>
</div>
 <div class="col-1" style="height:30px;">
  </div>



      <div class="col-2">
    <label>
      Position of Interest
      <select tabindex="1" id="poi" name="poi">
        <option>Vacant Position 1</option>
        <option>Vacant Position 2</option>
        <option>Vacant Position 3</option>
      </select>
    </label>
  </div>  
      <div class="col-2">
    <label>
      City Applied For
      <select tabindex="2" id="cityapplied" name="cityapplied">
        <option>Karachi</option>
        <option>Hyderabad</option>
        <option>Lahore</option>
        <option>Peshawar</option>
      </select>
    </label>
  </div> 

<!--<p>Personal Information</p>-->
  <div class="col-1" style="height:30px;">
  </div>
  <div class="col-1" style="background-color:#f4f4f3;">
<label>Personal Information</label>
</div>
 <div class="col-1" style="height:30px;">
  </div>


  <div class="col-1">
    <label>
      Name
      <input placeholder="What is your full name?" id="name" name="name" tabindex="3">
    </label>
  </div>                                                                              


  <div class="col-3">
    <label>
      Phone Number
      <input placeholder="What is the best # to reach you?" id="phone" name="phone" tabindex="4">
    </label>
  </div>
  <div class="col-3">
    <label>
      Email
      <input placeholder="What is your e-mail address?" id="email" name="email" tabindex="5">
    </label>
  </div>
  <div class="col-3">
    <label>
      Alternate Contact
      <input placeholder="What is your alternate number?" id="res" name="res" tabindex="6">
    </label>
  </div>


    <div class="col-2">
    <label>
      Date Of Birth
      <input placeholder="DD/MM/YYYY" id="dob" name="dob" tabindex="7">
    </label>
  </div>
<div class="col-2">
    <label>
      Place Of Birth
      <input placeholder="Place Of Birth" id="pob" name="pob" tabindex="8">
    </label>
  </div>

  <div class="col-2">
    <label>
      CNIC
      <input placeholder="xxxxx-xxxxxxx-x" id="cnic" name="cnic" tabindex="9">
    </label>
  </div>
  <div class="col-2">
    <label>
      Marital Status
      <input placeholder="Please type your marital status here" id="ms" name="ms" tabindex="10">
    </label>
  </div>

    <div class="col-2">
    <label>
      Present Address
      <input placeholder="Your current address" id="pa" name="pa" tabindex="11">
    </label>
  </div>
  <div class="col-2">
    <label>
      City of Residence
      <input placeholder="Your current city" id="cor" name="cor" tabindex="12">
    </label>
  </div>




<!--<p> Academic and Professional Qualification </p>-->
  <div class="col-1" style="height:30px;">
  </div>
  <div class="col-1" style="background-color:#f4f4f3;">
<label>Academic and Professional Qualification</label>
</div>
 <div class="col-1" style="height:30px;">
  </div>



  <div class="col-6">
    <label>
      Highest Degree Level
      <select tabindex="13" id="hdl" name="hdl">
        <option>Doctrate</option>
        <option>Masters</option>
        <option>Bachelors</option>
        <option>Diploma</option>
        <option>Certification</option>
        <option>Intermediate</option>
        <option>Matriculation</option>
      </select>
    </label>
  </div>
  <div class="col-6">
<label>
      Highest Degree Title
      <select tabindex="14" id="hdt" name="hdt">
        <option>Doctrate</option>
        <option>Masters</option>
        <option>Bachelors</option>
        <option>Diploma</option>
        <option>Certification</option>
        <option>Intermediate</option>
        <option>Matriculation</option>
      </select>
    </label>
  </div>
  <div class="col-6">
    <label>
      Highest Degree Discipline
      <select tabindex="15" id="hdd" name="hdd">
        <option>Doctrate</option>
        <option>Masters</option>
        <option>Bachelors</option>
        <option>Diploma</option>
        <option>Certification</option>
        <option>Intermediate</option>
        <option>Matriculation</option>
      </select>
    </label>
  </div>
  <div class="col-6">
    <label>
      Year Passed
      <input placeholder="YYYY" id="hyp" name="hyp" tabindex="16">
    </label>
  </div>
  <div class="col-6">
    <label>
      Division/GPA/Grade
     <input placeholder="Division/GPA/Grade" id="hdgg" name="hdgg" tabindex="17">
    </label>
  </div>
  <div class="col-6">
    <label>
      Highest Degree Institution
      <select tabindex="18" id="hdi" name="hdi">
        <option>Doctrate</option>
        <option>Masters</option>
        <option>Bachelors</option>
        <option>Diploma</option>
        <option>Certification</option>
        <option>Intermediate</option>
        <option>Matriculation</option>
      </select>
    </label>
  </div>


  <div class="col-6">
    <label>
      Secondary Degree Level
      <select tabindex="19" id="sdl" name="sdl">
        <option>Doctrate</option>
        <option>Masters</option>
        <option>Bachelors</option>
        <option>Diploma</option>
        <option>Certification</option>
        <option>Intermediate</option>
        <option>Matriculation</option>
      </select>
    </label>
  </div>
  <div class="col-6">
<label>
      Secondary Degree Title
      <select tabindex="20" id="sdt" name="sdt">
        <option>Doctrate</option>
        <option>Masters</option>
        <option>Bachelors</option>
        <option>Diploma</option>
        <option>Certification</option>
        <option>Intermediate</option>
        <option>Matriculation</option>
      </select>
    </label>
  </div>
  <div class="col-6">
    <label>
      Secondary Degree Discipline
      <select tabindex="21" id="sdd" name="sdd">
        <option>Doctrate</option>
        <option>Masters</option>
        <option>Bachelors</option>
        <option>Diploma</option>
        <option>Certification</option>
        <option>Intermediate</option>
        <option>Matriculation</option>
      </select>
    </label>
  </div>
  <div class="col-6">
    <label>
      Year Passed
      <input placeholder="YYYY" id="syp" name="syp" tabindex="22">
    </label>
  </div>
  <div class="col-6">
    <label>
      Division/GPA/Grade
     <input placeholder="Division/GPA/Grade" id="sdgg" name="sdgg" tabindex="23">
    </label>
  </div>
  <div class="col-6">
    <label>
      Secondary Degree Institution
      <select tabindex="24" id="sdi" name="sdi">
        <option>Doctrate</option>
        <option>Masters</option>
        <option>Bachelors</option>
        <option>Diploma</option>
        <option>Certification</option>
        <option>Intermediate</option>
        <option>Matriculation</option>
      </select>
    </label>
  </div>


<!--<p>Employement History</p>-->

  <div class="col-1" style="height:30px;">
  </div>
  <div class="col-1" style="background-color:#f4f4f3;">
<label>Employement History</label>
</div>
 <div class="col-1" style="height:30px;">
  </div>

    <div class="col-5">
    <label>
      Current Company
      <input placeholder="Where do you currently work?" id="ccompany" name="ccompany" tabindex="25">
    </label>
  </div>
    <div class="col-5">
    <label>
      Current Designation
      <input placeholder="What is your current designation?" id="cdesig" name="cdesig" tabindex="26">
    </label>
  </div>
      <div class="col-5">
    <label>
      Current Job Nature of Business
      <input placeholder="" id="cjnb" name="cjnb" tabindex="27">
    </label>
  </div>
    <div class="col-5">
    <label>
      Joining Date
      <input placeholder="YYYY-MM-DD" id="cfrom" name="cfrom" tabindex="28" >
    </label>
  </div>
  <div class="col-5">
    <label>
      Required Notice Period
       <select tabindex="29" id="rnp" name="rnp">
        <option>7 days</option>
        <option>14 days</option>
        <option>30 days</option>
        <option>More than 30 days</option>
      </select>
    </label>
  </div>


  <div class="col-5">
    <label>
      Last Company
      <input placeholder="Where did you work before your current company?" id="lcompany" name="lcompany" tabindex="29">
    </label>
  </div>
    <div class="col-5">
    <label>
      Last Designation
      <input placeholder="What was your desingation at your last company?" id="ld" name="ld" tabindex="30">
    </label>
  </div>
  <div class="col-5">
    <label>
      Last Job Nature of Business
      <input placeholder="" type="text" id="ljnb" name="lnjb" tabindex="31">
    </label>
  </div>
      <div class="col-5">
    <label>
      Joining Date
      <input placeholder="YYYY-MM-DD" type="text" id="LFrom" name="LFrom" tabindex="32">
    </label>
  </div>
    <div class="col-5">
    <label>
      Leaving Date
      <input placeholder="YYYY-MM-DD" type="text" id="LTo" name="LTo" tabindex="33">
    </label>
  </div>


    <div class="col-2">
    <label>
      Willingness to relocate anywhere in Pakistan
      <select tabindex="34" id="relocate" name="relocate">
        <option>Yes</option>
        <option>No</option>
        <option>Depends</option>
      </select>
    </label>
  </div>
  <div class="col-2">
    <label>
      Years Of Experience
      <input placeholder="Years of Experience" id="yoe" name="yoe" tabindex="35">
    </label>
  </div>


  <div class="col-1" style="height:30px;">
  </div>
  <div class="col-1" style="background-color:#f4f4f3;">
<label>Professional Preference</label>
</div>
 <div class="col-1" style="height:30px;">
  </div>

  <div class="col-3">
  <label>
      First Field Preference
      <select tabindex="36" id="ffp" name="ffp">
        <option>Field 1</option>
        <option>FIeld 2</option>
        <option>Field 3</option>
      </select>
    </label>
  </div>
  <div class="col-3">
    <label>
      Second Field Preference
      <select tabindex="37" id="sfp" name="sfp">
        <option>Field 1</option>
        <option>FIeld 2</option>
        <option>Field 3</option>
      </select>
    </label>
  </div>
  <div class="col-3">
    <label>
      Third Field Preference
      <select tabindex="38" id="tfp" name="tfp">
        <option>Field 1</option>
        <option>FIeld 2</option>
        <option>Field 3</option>
      </select>
    </label>
  </div>



  <div class="col-1" style="height:30px;">
  </div>
  <div class="col-1" style="background-color:#f4f4f3;">
<label>Salary Details</label>
</div>
 <div class="col-1" style="height:30px;">
  </div>


    <div class="col-2">
    <label>
      Gross Monthly Salary
      <input placeholder="Current Salary" id="csal" name="csal" tabindex="39">
    </label>
  </div>
<div class="col-2">
    <label>
      Expected Salary
      <input placeholder="Expected Salary" id="esal" name="esal" tabindex="40">
    </label>
  </div>


    <div class="col-4">
    <label>
      Provident Fund (PKR)
      <input placeholder="" id="pf" name="pf" tabindex="41">
    </label>
  </div>
  <div class="col-4">
    <label>
      Gratuity (PKR)
      <input placeholder="" id="gr" name="gr" tabindex="42">
    </label>
  </div>
      <div class="col-4">
    <label>
      LFA (PKR)
      <input placeholder="" type="text" id="lfa" name="lfa" tabindex="43">
    </label>
  </div>
    <div class="col-4">
    <label>
      Medical OPD Limit (PKR)
      <input placeholder="" type="text" id="mol" name="mol" tabindex="44">
    </label>
  </div>



      <div class="col-3">
    <label>
      Incentive (PKR)
      <input placeholder="If any" id="incentive" name="incentive" tabindex="45">
    </label>
  </div>
  <div class="col-3">
    <label>
      Bonus/Variable Pay (PKR)
      <input placeholder="" id="bv" name="bv" tabindex="46">
    </label>
  </div>
      <div class="col-3">
    <label>
      Tel/Mobile Allowance (PKR)
      <input placeholder="" type="text" id="tmo" name="tmo" tabindex="47">
    </label>
  </div>



    <div class="col-3">
    <label>
      Car/Motorcycle
      <input placeholder="" id="car" name="car" tabindex="48">
    </label>
  </div>
  <div class="col-3">
    <label>
      Fuel Limit (Ltrs.)
      <input placeholder="" id="fl" name="fl" tabindex="49">
    </label>
  </div>
      <div class="col-3">
    <label>
      Vehicle Maintenance (PKR)
      <input placeholder="" type="text" id="vm" name="vm" tabindex="50">
    </label>
  </div>


      <div class="col-4">
    <label>
      Group Life Insurance
      <select tabindex="24" id="gpl" name="gpl">
        <option>Yes</option>
        <option>No</option>
      </select>
    </label>
  </div>
  <div class="col-4">
    <label>
      Furnishing
      <input placeholder="" id="furnish" name="furnish" tabindex="51">
    </label>
  </div>
      <div class="col-4">
    <label>
      Leaves (Days)
      <input placeholder="" type="text" id="leaves" name="leaves" tabindex="52">
    </label>
  </div>
    <div class="col-4">
    <label>
      Other Benefits
      <input placeholder="If any" type="text" id="ob" name="ob" tabindex="53">
    </label>
  </div>


  <div class="col-1" style="height:30px;">
  </div>
  <div class="col-1" style="background-color:#f4f4f3;">
<label>References</label>
</div>
 <div class="col-1" style="height:30px;">
  </div>
      <div class="col-5">
    <label>
      Reference Name 1
      <input placeholder="" id="rn1" name="rn1" tabindex="54">
    </label>
  </div>
  <div class="col-5">
    <label>
      Contact
      <input placeholder="" id="rcontact1" name="rcontact1" tabindex="55">
    </label>
  </div>
      <div class="col-5">
    <label>
      Email
      <input placeholder="" type="text" id="remail1" name="remail1" tabindex="56">
    </label>
  </div>
    <div class="col-5">
    <label>
      Designation
      <input placeholder="" type="text" id="rdesig1" name="rdesig1" tabindex="57">
    </label>
  </div>
  <div class="col-5">
    <label>
      Company
      <input placeholder="" id="rcompany1" name="rcompany1" tabindex="58">
    </label>
  </div>


      <div class="col-5">
    <label>
      Reference Name 2
      <input placeholder="" id="rname2" name="rname2" tabindex="59">
    </label>
  </div>
  <div class="col-5">
    <label>
      Contact
      <input placeholder="" id="rcontact2" name="rcontact2" tabindex="60">
    </label>
  </div>
      <div class="col-5">
    <label>
      Email
      <input placeholder="" type="text" id="remail2" name="remail2" tabindex="61">
    </label>
  </div>
    <div class="col-5">
    <label>
      Designation
      <input placeholder="" type="text" id="rdesig2" name="rdesig2" tabindex="62">
    </label>
  </div>
  <div class="col-5">
    <label>
      Company
      <input placeholder="" type="text" id="rcompany2" name="rcompany2" tabindex="63">
    </label>
  </div>  

  <div class="col-1" style="height:30px;">
  </div>
  <div class="col-1" style="background-color:#f4f4f3;">
<label>Uploads</label>
</div>
 <div class="col-1" style="height:30px;">
  </div>  


      <div class="col-2">
    <label>
      Upload Your Resume
      <input placeholder="" type="file" id="fileToUpload" name="fileToUpload" tabindex="64">
    </label>
  </div>
  <div class="col-2">
    <label>
      Upload Your Photo
      <input placeholder="" type="file" id="fileToUpload2" name="fileToUpload2" tabindex="65">
    </label>
  </div>  



  <div class="col-submit">
    <button class="submitbtn">Submit Form</button>
  </div>

  </form>
  </div>

<script type="text/javascript">
var elems = Array.prototype.slice.call(document.querySelectorAll('.js-switch'));

elems.forEach(function(html) {
  var switchery = new Switchery(html);
});
</script>
</body>
</html>

更新2:PHP代码 - 仅相关部分

<?php
if (isset($_POST['mySubmitButton'])) {

    // All the posted value
    $cfrom = htmlentities($_POST['cfrom']); // Escape your post values

}
echo "here we go:".$cfrom;

.
.
.
$ccompany=$_POST['ccompany'];
$cdesig=$_POST['cdesig'];
$cjnb=$_POST['cjnb'];
$cfrom=$_POST['cfrom'];
$rnp=$_POST['rnp'];
$lcompany=$_POST['lcompany'];
$ld=$_POST['ld'];
$lnjb=$_POST['lnjb'];
.
.
.

?>

更新3:错误日志

[24-Oct-2015 14:48:23 Europe/Paris] **********************DEBUG************************

[24-Oct-2015 14:48:23 Europe/Paris] PHP Notice:  Undefined variable: cfrom in C:\wamp\www\careers\save.php on line 23

[24-Oct-2015 14:48:23 Europe/Paris] PHP Stack trace:

[24-Oct-2015 14:48:23 Europe/Paris] PHP   1. {main}() C:\wamp\www\careers\save.php:0

[24-Oct-2015 14:48:23 Europe/Paris] PHP Deprecated:  mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\wamp\www\careers\save.php on line 101

[24-Oct-2015 14:48:23 Europe/Paris] PHP Stack trace:

[24-Oct-2015 14:48:23 Europe/Paris] PHP   1. {main}() C:\wamp\www\careers\save.php:0

[24-Oct-2015 14:48:23 Europe/Paris] PHP   2. mysql_connect() C:\wamp\www\careers\save.php:101

[24-Oct-2015 14:48:23 Europe/Paris] PHP Notice:  Undefined index: cfrom in C:\wamp\www\careers\save.php on line 146

[24-Oct-2015 14:48:23 Europe/Paris] PHP Stack trace:

[24-Oct-2015 14:48:23 Europe/Paris] PHP   1. {main}() C:\wamp\www\careers\save.php:0

[24-Oct-2015 14:48:23 Europe/Paris] PHP Notice:  Undefined index: LFrom in C:\wamp\www\careers\save.php on line 151

[24-Oct-2015 14:48:23 Europe/Paris] PHP Stack trace:

[24-Oct-2015 14:48:23 Europe/Paris] PHP   1. {main}() C:\wamp\www\careers\save.php:0

[24-Oct-2015 14:48:23 Europe/Paris] PHP Notice:  Undefined index: LTo in C:\wamp\www\careers\save.php on line 152

[24-Oct-2015 14:48:23 Europe/Paris] PHP Stack trace:

[24-Oct-2015 14:48:23 Europe/Paris] PHP   1. {main}() C:\wamp\www\careers\save.php:0

[24-Oct-2015 14:48:23 Europe/Paris] PHP Notice:  Undefined index: lfa in C:\wamp\www\careers\save.php on line 162

[24-Oct-2015 14:48:23 Europe/Paris] PHP Stack trace:

[24-Oct-2015 14:48:23 Europe/Paris] PHP   1. {main}() C:\wamp\www\careers\save.php:0

[24-Oct-2015 14:48:23 Europe/Paris] PHP Notice:  Undefined index: mol in C:\wamp\www\careers\save.php on line 163

[24-Oct-2015 14:48:23 Europe/Paris] PHP Stack trace:

[24-Oct-2015 14:48:23 Europe/Paris] PHP   1. {main}() C:\wamp\www\careers\save.php:0

[24-Oct-2015 14:48:23 Europe/Paris] PHP Notice:  Undefined index: tmo in C:\wamp\www\careers\save.php on line 166

[24-Oct-2015 14:48:23 Europe/Paris] PHP Stack trace:

[24-Oct-2015 14:48:23 Europe/Paris] PHP   1. {main}() C:\wamp\www\careers\save.php:0

[24-Oct-2015 14:48:23 Europe/Paris] PHP Notice:  Undefined index: vm in C:\wamp\www\careers\save.php on line 169

[24-Oct-2015 14:48:23 Europe/Paris] PHP Stack trace:

[24-Oct-2015 14:48:23 Europe/Paris] PHP   1. {main}() C:\wamp\www\careers\save.php:0

[24-Oct-2015 14:48:23 Europe/Paris] PHP Notice:  Undefined index: gpl in C:\wamp\www\careers\save.php on line 170

[24-Oct-2015 14:48:23 Europe/Paris] PHP Stack trace:

[24-Oct-2015 14:48:23 Europe/Paris] PHP   1. {main}() C:\wamp\www\careers\save.php:0

[24-Oct-2015 14:48:23 Europe/Paris] PHP Notice:  Undefined index: leaves in C:\wamp\www\careers\save.php on line 172

[24-Oct-2015 14:48:23 Europe/Paris] PHP Stack trace:

[24-Oct-2015 14:48:23 Europe/Paris] PHP   1. {main}() C:\wamp\www\careers\save.php:0

[24-Oct-2015 14:48:23 Europe/Paris] PHP Notice:  Undefined index: ob in C:\wamp\www\careers\save.php on line 173

[24-Oct-2015 14:48:23 Europe/Paris] PHP Stack trace:

[24-Oct-2015 14:48:23 Europe/Paris] PHP   1. {main}() C:\wamp\www\careers\save.php:0

[24-Oct-2015 14:48:23 Europe/Paris] PHP Notice:  Undefined index: remail1 in C:\wamp\www\careers\save.php on line 176

[24-Oct-2015 14:48:23 Europe/Paris] PHP Stack trace:

[24-Oct-2015 14:48:23 Europe/Paris] PHP   1. {main}() C:\wamp\www\careers\save.php:0

[24-Oct-2015 14:48:23 Europe/Paris] PHP Notice:  Undefined index: rdesig1 in C:\wamp\www\careers\save.php on line 177

[24-Oct-2015 14:48:23 Europe/Paris] PHP Stack trace:

[24-Oct-2015 14:48:23 Europe/Paris] PHP   1. {main}() C:\wamp\www\careers\save.php:0

[24-Oct-2015 14:48:23 Europe/Paris] PHP Notice:  Undefined index: rcompany1 in C:\wamp\www\careers\save.php on line 178

[24-Oct-2015 14:48:23 Europe/Paris] PHP Stack trace:

[24-Oct-2015 14:48:23 Europe/Paris] PHP   1. {main}() C:\wamp\www\careers\save.php:0

[24-Oct-2015 14:48:23 Europe/Paris] PHP Notice:  Undefined index: remail2 in C:\wamp\www\careers\save.php on line 181

[24-Oct-2015 14:48:23 Europe/Paris] PHP Stack trace:

[24-Oct-2015 14:48:23 Europe/Paris] PHP   1. {main}() C:\wamp\www\careers\save.php:0

[24-Oct-2015 14:48:23 Europe/Paris] PHP Notice:  Undefined index: rdesig2 in C:\wamp\www\careers\save.php on line 182

[24-Oct-2015 14:48:23 Europe/Paris] PHP Stack trace:

[24-Oct-2015 14:48:23 Europe/Paris] PHP   1. {main}() C:\wamp\www\careers\save.php:0

[24-Oct-2015 14:48:23 Europe/Paris] PHP Notice:  Undefined index: rcompany2 in C:\wamp\www\careers\save.php on line 183

[24-Oct-2015 14:48:23 Europe/Paris] PHP Stack trace:

[24-Oct-2015 14:48:23 Europe/Paris] PHP   1. {main}() C:\wamp\www\careers\save.php:0

4 个答案:

答案 0 :(得分:1)

无法看到当前提供的代码存在任何问题。

建议是在提交按钮上添加name="mySubmitButton"并添加type="submit"属性。

然后PHP将是:

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

    // All the posted value
    $cfrom = htmlentities($_POST['cfrom']); // Escape your post values

}

答案 1 :(得分:0)

首先检查开发者工具的网络标签中的请求,如果上面提到的字段不存在,那就意味着你的html中有拼写错误。

答案 2 :(得分:0)

尝试使用print_r($ _ POST)打印所有帖子值;在你的save.php脚本之上。

我尝试了相同的表单,我得到了你上面提到的值($ _POST ['cfrom'])。

如果您在打印发布数据时也获得了值,那么您可能在代码下面做错了。

答案 3 :(得分:0)

当您获得未定义的索引时,通常意味着您的表单输入名称与$ _POST索引不匹配,建议是记录变量并查看您获得的内容:

error_log('**********************DEBUG************************');
ob_start();
var_dump($_POST);
$postBack = ob_get_contents();
ob_end_clean();
error_log($postBack);
error_log('**********************DEBUG************************');

然后从日志中复制粘贴以创建验证:

if(isset($_POST['ccompany'],$_POST['cdesig'],$_POST['cjnb'],$_POST['cfrom'],$_POST['rnp'],$_POST['lcompany'],$_POST['ld'],$_POST['lnjb'])){
    $ccompany=$_POST['ccompany'];
    $cdesig=$_POST['cdesig'];
    $cjnb=$_POST['cjnb'];
    $cfrom=$_POST['cfrom'];
    $rnp=$_POST['rnp'];
    $lcompany=$_POST['lcompany'];
    $ld=$_POST['ld'];
    $lnjb=$_POST['lnjb'];
}else{
    echo "missing variable check log";
}