Function to call

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jamhussain
Forum Newbie
Posts: 17
Joined: Sat Apr 07, 2012 2:04 am

Function to call

Post by jamhussain »

<?php
session_start();

// For radio buttons to get the value from Form.
if (isset($_POST['submit'], $_POST['type']))
{
$type = $_POST['type'];
$_SESSION['a'][0] = (int)$type;
if( !empty( $_SESSION['a'][0] ) )
{
$b = $_SESSION['a'][0];

}


}
?>

it is the code that I use for getting the values from Radio buttons.
But I want to use the Class . I want to use the Function in this class.
so that value of Variable $b can be called at any page.
I want to use $b for further calculations at other pages also.
so what is its solution.
i think, is its solution Classes and functions.
If yes, then how can be code of this function and class.
thanks
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Function to call

Post by requinix »

Are you saying you want to use classes and functions? Or are you just trying to use sessions?

If it's the latter then you're already there. Once that code executes, any other page can call session_start() and use $_SESSION['a'][0] too.
jamhussain
Forum Newbie
Posts: 17
Joined: Sat Apr 07, 2012 2:04 am

Re: Function to call

Post by jamhussain »

But in this case I use the variable
$b = $_SESSION['a'][0];
$c=$b*4;
Now I want to use this variable $C value in another page or Graph page.(graph.php)
this variable is not accessable here.
that is problem to solve.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Function to call

Post by requinix »

Stick it in the session.

Code: Select all

$_SESSION['c'] = $c;
and use that instead.
Post Reply