Jump to content

Recommended Posts

I am working on an "online employment application".  Consequently it has about 83 fields.  Rather than $name=$_POST['name']; 83 times ... is there a way to get everything that is posted as an array and store it in a database accordingly?

 

("insert into apps ONE ARRAY") as opposed to:

 

 


if (isset($_POST['application'])){ // put all into an array

        $_POST['FnameTxt'];
        $_POST['LnameTxt'];
        $_POST['AddressTxt'];
        $_POST['CityTxt'];
        $_POST['StateTxt'];
        $_POST['ZipTxt'];
        $_POST['CountryLst'];
        $_POST['EmailTxt'];
        $_POST['PhoneNum'];
        $_POST['FaxNum'];
        $_POST['desiredPosition'];
        $_POST['otherPosition'];
        $_POST['StartofWork'];
        $_POST['Employer'];
        $_POST['employerAddressTxt'];
        $_POST['From'];
        $_POST['To'];
        $_POST['Supervisor'];
        $_POST['Salary'];
        $_POST['Work'];
        $_POST['Reason'];
        $_POST['Employer2'];
        $_POST['employerAddressTxt2'];
        $_POST['From2'];
        $_POST['To2'];
        $_POST['Supervisor2'];
        $_POST['Salary2'];
        $_POST['Work2'];
        $_POST['Reason2'];
        $_POST['Employer3'];
        $_POST['employerAddressTxt3'];
        $_POST['From3'];
        $_POST['To3'];
        $_POST['Supervisor3'];
        $_POST['Salary3'];
        $_POST['Work3'];
        $_POST['Reason3'];
        $_POST['HSName'];
        $_POST['HSLocation'];
        $_POST['HSMajor'];
        $_POST['HSDiploma'];
        $_POST['HSYear'];
        $_POST['UnivName'];
        $_POST['UnivLocation'];
        $_POST['UnivMajor'];
        $_POST['UnivDiploma'];
        $_POST['UnivYear'];
        $_POST['UnivName1'];
        $_POST['UnivLocation1'];
        $_POST['UnivMajor1'];
        $_POST['UnivDiploma1'];
        $_POST['UnivYear1'];
        $_POST['TradeName'];
        $_POST['TradeLocation'];
        $_POST['TradeMajor'];
        $_POST['TradeDiploma'];
        $_POST['TradeYear'];
        $_POST['Q1'];
        $_POST['Q2'];
        $_POST['Q3'];
        $_POST['Q4'];
        $_POST['Q5'];
        $_POST['Q6'];
        $_POST['Q7'];
        $_POST['Q8'];
        $_POST['Q9'];
        $_POST['Q10'];
        $_POST['Q11'];
        $_POST['refName'];
        $_POST['occupation'];
        $_POST['refAddressTxt'];
        $_POST['refPhone'];
        $_POST['Relationship'];
        $_POST['Known'];
        $_POST['refName1'];
        $_POST['occupation1'];
        $_POST['refAddressTxt1'];
        $_POST['refPhone1'];
        $_POST['Relationship1'];
        $_POST['Known1'];
        $_POST['gender'];
        $_POST['ethnic'];
        $_POST['howrefered'];

} // seems like a lot of redundant typing

 

Any suggestions would be greatly appreciated.

 

-Ant

Hi,

 

I think you should starting with the forms structures. You use one form now for those datas. Rather you should use more forms (structured by logically isolated parts).

You would to show over the users through the forms...

 

Example:

Personal details

Human resources details

...

function SQLclean($val)
{
   if (ctype_digit($val))
   {
      return $val;
   }else{
      return "'" . mysql_real_escape_string($val) . "'";
   }
}


if (isset($_POST['submit']))
{
   unset($_POST['submit']);
   $fields = array_keys($_POST);
   $values = array_walk($_POST, 'SQLclean');
   $query = "INSERT INTO tableName ( `" . implode('`,', $fields) . "` ) VALUES ( " . implode(', ', $values) ." )";
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.