Jump to content

Reading GET/POST with includes


cooldude832

Recommended Posts

I have this skelton design for a site i'm working on that uses a system of 3 files

 

the file a user request looks like

<?php 
$page = "search";
$title = "Search For Facilitators and Events";
require_once('constants.php');
require_once(SCRIPTS.'shell.php');
?>

 

Then the shell which is the skeleton of it in xhtml looks like

<?php 
session_start();
require_once("functions.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="" />
<meta name="keywords" content=""
	/>
<meta name="authors" content="" />
<meta name="copyright" content="September 2007 -- Present" />
<meta name="distribution" content="global" />
<link rel="stylesheet" type="text/css" href="<?php echo CSS;?>index.css" />
<link rel="shortcut icon" href="<?php echo GRAPHICS;?>favicon.ico" />
<title><?php echo $title;?></title>
</head>
<body>
<div id="container">
<div id="header">
<a href="<?php echo BASE;?>">
	<img src="<?php echo GRAPHICS;?>logo.png" alt="" class="logo" border="0" />
</a>
</div>
<div id="navi_menu">
<?php require("left_navi.html");?>
</div>
<div id="content">
<?php require(SUB_FOLDER.$page.EXT);?>
</div>

<div id="footer">
<?php require("footer.html");?>
</div>
</div>
</body>
</html>

 

Then from that it loads the content area of the page with that line

<?php require(SUB_FOLDER.$page.EXT);?>

 

In the file that is used in the above stated line I am trying to read the get/post data and I can not.  However if I read it in the shell.php with the identical code it works fine.  Anyone have any idea that can help me here, I'm stumped because I've done a similar idea before,  with no issues. 

 

I can read get/post, I just can't do it in the file I want.  I'd prefer not to, but if I have to would I have to make something like

<?php
foreach ($_GET as $key => $value){
	$get[$key] = $value;
}
?>

To take it out of that super global?  I'd prefer not to, but I have a feeling it will be my only choice, as I can not read the Superglobals in the include file.

 

However I can use the $_SERVER variables in the include so I'm really stumped.

Link to comment
Share on other sites

okay i turned error reporting on to

error_reporting(6143);

 

now when I try and read get with a foreach it doesn't fail, however it displays nothing, and when I try and use a get value that is set I get an unidentified index error.  So it is sending it, but this file can't read it. ?? ??? ???

Link to comment
Share on other sites

I tries using the global $_GET/ global $_REQUEST no results.  I just don't get how a superglobal array can not be used in an include that is in an include

such as

serach.php includes (shell.php) which includes (sources/search.php "the file I want to read the superglobals in)

 

I also treid this on a secondary server with the same issues.

Link to comment
Share on other sites

tried doing this and it gives me an index error in the decleration of the $get = $post = part

<?php
$get = $GLOBALS['get'];
$post = $GLOBALS['post'];
echo "GET COUNT: ".count($get)."<br />POST COUNT: ".count($post)."<br />";
?>

the shell file has

<?php 
foreach($_GET as $key => $value){
	$get[$key] = $value;
}
foreach($_POST as $key => $value){
	$POST[$key] = $value;
}
?>

 

However in the footer I can echo it out saying

<?php
	echo "GET COUNT: ".count($get)."<br />POST COUNT: ".count($post)."<br />";
?>

 

And it works fine

Link to comment
Share on other sites

another note: I ran

<?php
foreach($GLOBALS as $key => $value){
echo $key.": ".$value."<br />";
}
?>

and I found a few interesting things

 

REQUEST_METHOD: GET

QUERY_STRING:

REQUEST_URI: /redesign/source/search.php

SCRIPT_NAME: /redesign/source/search.php

 

 

The request_method makes sense, but the query string shouldn't be empty and it is

 

Also the Script_name is the include not the parent document.  Any ideas be very helpful.  I'm at the point of just scrapin this layout for the serach page and just make it indepdent so I don't have to deal with all the issues.

Link to comment
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.