Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Passing values via $insertGoTo?

Guest
May 27, 2010 May 27, 2010

Hello all,

I am using the canonical Dreamweaver/PHP construct to direct to another php page upon submit.

$insertGoTo = "confirm_submission.php";
if (isset($_SERVER['QUERY_STRING'])) {
  $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
  $insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));

Is it possible to pass additional values to the "confirm_submission.php" page?  I know how to do this using a regular URL GET method.  Doing so with the above construct is a bit less clear.

I neglected to mention that these are form variables that I am interested in passing.

Thanks!

Message was edited by: ByteSmythe (added clarity regarding form variables)

TOPICS
Server side applications
2.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , May 28, 2010 May 28, 2010

Yeah. Use the if/else to check and append the first value but after that it's safe to assume that the querystring exists so just concatenate the other key/values pairs.

>Also, I have one value that I want to pass hidden.

I'd probably use a session variable for that.

Translate
Guest
May 27, 2010 May 27, 2010

I found an old post by David that suggests

  // if a query string has been added, add the value at the end
  // otherwise, create a query string to add value
  if (strpos($insertGoTo, '?')) {
   $insertGoTo .= '&rep_fname=' . $_POST['RepFname'];
  } else {
   $insertGoTo .= '?rep_fname=' . $_POST['RepFname'];
  }

  header(sprintf("Location: %s", $insertGoTo));

Which appears to work when I access the variable via $_GET['rep_fname'] in the php file to which the user is redirected.  It seems a pity to have to do this for 10 variables but I suspect this is cleaner than using something a global session variable ($_SESSION).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 27, 2010 May 27, 2010

>It seems a pity to have to do this for 10 variables

You probably don't need to test if the querystring exist for anything except the first value. That will streamline things quite a bit.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 27, 2010 May 27, 2010

>You probably don't need to test if the querystring exist for anything except the first value. That will streamline things quite a bit.

Good point.  You're saying simply concatenate the remainder onto $insertGoTo?

Also, I have one value that I want to pass hidden.  What is the best way to do that?  As a form value?  Sorry if this is an FAQ.  I am a long time HTML/CGI programmer and new to PHP via Dreamweaver.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 28, 2010 May 28, 2010

Yeah. Use the if/else to check and append the first value but after that it's safe to assume that the querystring exists so just concatenate the other key/values pairs.

>Also, I have one value that I want to pass hidden.

I'd probably use a session variable for that.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 28, 2010 May 28, 2010

Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 10, 2010 Jun 10, 2010

> I'd probably use a session variable for that.

If a user blocks cookies won't that effect the ability to use session variables?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 10, 2010 Jun 10, 2010
LATEST

>If a user blocks cookies won't that

>effect the ability to use session  variables?

Yep. It's difficult to build secure systems without sessions. Modern browsers typically allow the user come control over what types of cookies they will allow, such as only allowing session cookies. It's hard to surf the net these days if you are blocking all cookies.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines