Jump to content

SESSION to REQUEST


derno

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.