Jump to content

Passing values --- really annoying me....


~n[EO]n~

Recommended Posts

back again ;

 

I will start immediately

 

The problem is that I have 3 different pages (classic, business and VIP) which links to the contact.php page

and in these 3 pages there are 3 different banners, menu and footer. And in the (3) footer file there is one common link to the contact page

 

what i did was from the Classic footer i passed this value

<a href="contacts.php?frompage=Classic" class="bottom_link">contact</a>

 

and from the business footer i passed this

<a href="contacts.php?frompage=Business" class="bottom_link">contact</a>

 

and from VIP footer i passed this

<a href="contacts.php?frompage=VIP" class="bottom_link">contact</a>

 

and in the contacts.php page i did this

<?php $mypage = $_REQUEST['frompage']; ?>

 

and from this variable i managed the header, menu and footer

<?php 
	if ($mypage=='Classic') 
	{
	include("includes/header_classic.php"); 
	}
	elseif ($mypage=='Business') 
	{
	include("includes/header_business.php");
	}
	elseif ($mypage=='VIP')
	{
	include("includes/header_vip.php");
	}
	?>

 

same code follows for menu and footer

 

But what happened is when i Submit the form and save the information in database (all the values) gets saved, the header, menu and the footer gets lost...

 

I know because while submitting $mypage variable gets blank and due to this the headers are not showing, how shall i retain the value from this variable while i submit the form or the page refreshes..

 

Please someone help...

 

 

Link to comment
https://forums.phpfreaks.com/topic/71809-passing-values-really-annoying-me/
Share on other sites

You'l most likely need to use sessions, I don't know what your doing .. how-EVER, It looks to me like you are giving your users alot of control by passing Access Restrictions in the URL Bar. Users can change these values, which is a potential security risk.

 

I would save the users access level in a session variable.. that way you won't need to worry about passing variables around so much, only initially..

 

If you need help with this, just respond back.. I will give ya plenty of info if your willing to read. :P

Ok, yes i hadn't thought of that , but for now can you suggest how to save these names. Using Session is also not working

 

<?php $mypage=$_REQUEST['frompage'];

$_SESSION['currpage'] = $mypage;

$mynewpage = $_SESSION['currpage'];

?>

 

I tried this also but does not work,

 

<form name="frmcontact" method="post" action="contacts.php?frompage=<?=$mynewpage?>">
			  <input type='hidden' name='co_usertype' value="<?=$mypage;?>">

 

BTW, i will be glad to read your info, but please don't give a link to the websites.

 

Thanks a lot....

No don't have to do that cause it gets automatically started and it is done config.php file

 

here some codes from config.php file

 

<?php
//========config.php==========================
// application global configuration constants.
//------------------------
// intialize environment
session_name("sitename");
session_start();
set_magic_quotes_runtime(0);
//error_reporting(0);
// set default content type and encoding
header('Content-Type: text/html; charset=utf-8');
$path=realpath("./");
if(strpos($path,"admin")>0)
      $rootpath=realpath("../");
else
      $rootpath=realpath("./");


define('INCLUDES_DIR',$rootpath.'/includes/');
define('CLASS_DIR',$rootpath. '/classes/');

 

 

<?php
require_once("config.php");
require_once("user_info.class.php");
?>

 

cause in the user login page i haven't called Session_Start() and it is working fine...

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.