/    Sign up×
Community /Pin to ProfileBookmark

Function to call at other page

<?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

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMay 06.2012 — Well, it's already in $_SESSION as $_SESSION['a'][0], so you could just use that; or save it as a separate session variable if you prefer, e.g. $_SESSION['b'].
Copy linkTweet thisAlerts:
@jamhussainauthorMay 06.2012 — Actually, I get the value

$b = $_SESSION['a'][0];

$c=$b*4;

Now I use this $C valuefor further calcualtions and I use it for Graphs

i e graph.php

but this $c is not accessable at graph.php page.

how can I access it.thanks.
Copy linkTweet thisAlerts:
@NogDogMay 06.2012 — Like I said, save it as a session variable in $_SESSION (and don't forget to do a session_start() on each page where you need to read/write to the $_SESSION array).
×

Success!

Help @jamhussain spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...