Salik
Salik

Reputation: 518

Missing values in $_POST variables

I have an HTML form with around 65 input fields. The form uses POST method, and upon submission the fields are directed to a php script for database entry.nothing scientific.

However, there are few POST variables which generate undefined index warning and have empty values in corresponding database columns. I cannot seem to figure out why are few variables are generating undefined index warning while rest are doing just fine.

For an example, following is the html and php script for retrieving values using POST variables. cfrom generates the undefined index warning while cjnb works just fine. 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'];

I tried using isset and it sets the variable to empty value probably because it does not find a value in $_POST['cfrom'], however, i am entering a value in the cfrom input value.

Please Help!

UPDATE: FULL FORM

<!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>

UPDATE 2: PHP CODE - RELEVANT PARTS ONLY

<?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'];
.
.
.

?>

UPDATE 3: ERROR LOG

[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

Upvotes: 1

Views: 1827

Answers (4)

meda
meda

Reputation: 45500

When you get undefined index, it usually means your form input name dont match the $_POST index, Suggestion is to log the variables and see what you are getting:

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

Then copy paste from the log to create your validation:

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";
}

Upvotes: 0

Sk_
Sk_

Reputation: 1191

Try to print all the post values using print_r($_POST); on top of your save.php script.

I tried the same form and i got the value ($_POST['cfrom']) which you mentioned above.

If you also getting the value when you print the post data then you might be doing something wrong below the code.

Upvotes: 0

Jeroen Bellemans
Jeroen Bellemans

Reputation: 2035

Can't see any problems with the current provided code.

A suggestion would be to give a name="mySubmitButton" to the submit button and add type="submit" attribute.

Then the PHP would be:

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

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

}

Upvotes: 1

MoniXx
MoniXx

Reputation: 135

Start by checking the request in the network tab of your developer tools if the above mentioned field isnt there, that means you have a typo in your html.

Upvotes: 0

Related Questions