Welcome to WebmasterWorld Guest from 54.167.0.111

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Carrying information through multiple pages

     

FayeN

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

10+ Year Member



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

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

10+ Year Member



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

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

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

FayeN

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

10+ Year Member



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

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

10+ Year Member



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! ^^

 

Featured Threads

Hot Threads This Week

Hot Threads This Month