Author Topic: Passing values --- really annoying me....  (Read 742 times)

0 Members and 1 Guest are viewing this topic.

Offline ~n[EO]n~Topic starter

  • Devotee
  • Posts: 725
    • View Profile
Passing values --- really annoying me....
« on: October 04, 2007, 07:48:00 AM »
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
Code: [Select]
<a href="contacts.php?frompage=Classic" class="bottom_link">contact</a>
and from the business footer i passed this
Code: [Select]
<a href="contacts.php?frompage=Business" class="bottom_link">contact</a>
and from VIP footer i passed this
Code: [Select]
<a href="contacts.php?frompage=VIP" class="bottom_link">contact</a>
and in the contacts.php page i did this
Code: [Select]
<?php $mypage $_REQUEST['frompage']; ?>
and from this variable i managed the header, menu and footer
Code: [Select]
<?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...


Offline jscix

  • Enthusiast
  • Posts: 197
    • View Profile
Re: Passing values --- really annoying me....
« Reply #1 on: October 04, 2007, 07:53:58 AM »
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

Offline ~n[EO]n~Topic starter

  • Devotee
  • Posts: 725
    • View Profile
Re: Passing values --- really annoying me....
« Reply #2 on: October 04, 2007, 08:02:29 AM »
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

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

$_SESSION['currpage'] = $mypage;

$mynewpage $_SESSION['currpage'];

?>

I tried this also but does not work,

Code: [Select]
<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....

Offline jscix

  • Enthusiast
  • Posts: 197
    • View Profile
Re: Passing values --- really annoying me....
« Reply #3 on: October 04, 2007, 08:06:04 AM »
Well I'm gonna ask the obvious just to make sure -- You do have Session_Start() as the very, very, first thing on your page right? If so, that should be working.

Offline ~n[EO]n~Topic starter

  • Devotee
  • Posts: 725
    • View Profile
Re: Passing values --- really annoying me....
« Reply #4 on: October 04, 2007, 08:13:44 AM »
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

Code: [Select]
<?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/');


Code: [Select]
<?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...

Offline jscix

  • Enthusiast
  • Posts: 197
    • View Profile
Re: Passing values --- really annoying me....
« Reply #5 on: October 04, 2007, 08:23:33 AM »
Ok, Then ...

In your footer, after the user follows the link to: contact.php?frompage=business

and in your contacts.php, you have:

$_SESSION['var'] = $_GET['frompage'];

-------------

print $_SESSION['var'];

This should print 'business', does it?