Jump to content

Recommended Posts

Hello, im new here and I just have a quick question.

 

I'm making a 4 page form, that is HUGE (about 270 fields) and I'm using session. I was wondering if there is fast way to make all of the $_SESSION['fieldnamehere'] set to $_REQUEST['fieldnamehere']

 

The form works and send the info if i do this, but i dont want to type out all of the fields. Is there a faster way of doing this?

 

I have the whole form on 1 page for the email, and i use this to grab all the fields, which works if they're all set to $_REQUEST.

 

ob_end_flush();
ob_start();
include ('employment_form.php');
$message=ob_get_contents();
ob_end_clean();

Link to comment
https://forums.phpfreaks.com/topic/68101-session-to-request/
Share on other sites

foreach ($_POST as $key => $value)
{
   $_SESSION = array_flip($_SESSION);
   $_SESSION[] = $key;
   $_SESSION = array_flip($_SESSION);
   $_SESSION[$key] = $value;
}

 

I don't know a neater way to add the keys and values to an array other than flipping, maybe there is a better way.

Link to comment
https://forums.phpfreaks.com/topic/68101-session-to-request/#findComment-342331
Share on other sites

if they are truley the fieldnames you could

 

$querystring = "Select * from ".$DB;
  $result=mysql_query($querystring);
  while(($field = mysql_fetch_field($result))) {
     ${"{$field->name}"}  = $data22[$field->name];
  }

 

This queries the DB and sets variable name to field names.

 

Ex: Say we had

 

table: Users

with to 2 fields

First

Last

 

This loop would create two variables

$First

$Last

 

 

 

Maybe could replace

${"{$field->name}"}  = $data22[$field->name];

with

$_SESSION["{$field->name}"] = $_REQUEST["{$field->name}"]

 

Link to comment
https://forums.phpfreaks.com/topic/68101-session-to-request/#findComment-342332
Share on other sites

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.