homepage Welcome to WebmasterWorld Guest from 54.204.249.184
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Carrying information through multiple pages
FayeN




msg:1285623
 5:00 pm on Nov 2, 2003 (gmt 0)

I am designing an electronic voting system with PHP, mysql and apache. It is for an university. So right now you can vote for president, vice president, and senators based on your college. At the end I would like to be able to have a page that says

The president you voted for was_____
The vice president you voted was ____

To do this I will create a table with the user starts to vote creating a voter ID.. then I would like to be able to query the table on that page but I am not sure how I will match up the table with the above format.

Any help would be greatly appreciated.

[edited by: jatar_k at 4:36 am (utc) on Nov. 4, 2003]
[edit reason] spliced 2 posts together [/edit]

 

mapostel




msg:1285624
 5:16 pm on Nov 2, 2003 (gmt 0)

Hi FayeN,

For tracking and keeping state across several pages sessions are most common with PHP.

But of course you could also use a table to keep track of a user's activities, and a session could the be used to identify the user.

The PHP documentation has some information about sessions.

Hope this helps ...

jatar_k




msg:1285625
 4:31 am on Nov 4, 2003 (gmt 0)

Maybe try looking through these functions
PHP Session Handling Functions [ca3.php.net]

FayeN




msg:1285626
 10:21 pm on Nov 3, 2003 (gmt 0)

I am designing an electronic voting system with PHP, mysql and apache. It is for an university. So right now you can vote for president, vice president, and senators based on your college. At the end I would like to be able to have a page that says

The president you voted for was_____
The vice president you voted was ____

To do this I will create a table with the user starts to vote creating a voter ID.. then I would like to be able to query the table on that page but I am not sure how I will match up the table with the above format.

Any help would be greatly appreciated.

bobnew32




msg:1285627
 4:31 am on Nov 4, 2003 (gmt 0)

Lets say you store the ids in sessions. Heres how you'd do it

<?php

session_start();

$_SESSION['pres_id']= $pres_id;
?>

Then on the page you want to view it (and all pages on the site must have session_start said or else the session will fail)

<?php

session_start();

$pres_id= $_SESSION['pres_id'];

if($pres_id=='1')
{
$pres_name= 'George Washington';
}
elseif($pres_id=='2')
{
$pres_name= 'John Adams';
}

?>

You get the idea. Plus if its stored in a mysql table, you can use the following code to get started with that.

<?php
$sql = "SELECT * FROM table WHERE pres_id = $pres_id";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);

print $row['name'];
?>

I gave you some info to start with, have fun with it. Change it, intermingle it and learn from it! ^^

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved