Hello peoples. I have a voting system on my web site that uses 3 files. The first file is vote.php and has the vote form on it. This file passes the information to confirmation.php which has a thank you message on it. This file passes the information to vote.txt, which stores the information for me to tally up later. What i described to you works great, but theres one problem. I want users to have to log in first, using a login form on voteli.php. I have login scripts, but theyre not even close to secure. I want it so if they get smart and go directly to vote.php it will kick them back to voteli.php unless varaible $login is true. I would also like the login script to pass the username through all the pages as varaible $user. Then i wil echo the varaible in the page so it has a greeting message. I will also use this name in the results page to cancel out any double votes by the same user. I will provide the source codes i made using my small knowledge of php, and i will hope that you suggest some fixes.
vote.php:
[PHP]<?php
$login = $_GET['login'];
$user = $_GET['username']
if(!$login)
{
window.location=('voteli.htm');
}
else
{
echo('Hello, '$user'!');
}
?>[/PHP]The code above is the one i wrote to bounce the users back to the login page if they have not logged in. It also prints the hello message at the top of the vote page.
[HTML]
<?php echo('Voting as: '$user'.') ?>
<form name="poll" action="confirmation.php" method="get">
Lorem ipsum sit dolor amet?
<select name="q1">
<option value="q1a">Lorem</option>
<option value="q1b">Ipsum</option>
<option value="q1c">Dolor</option>
<option value="q1d">Amet</option>
</select>
</form>[/HTML]
The code above is the simplified vote form.
confirmation.php
[HTML]<?php
$q1 = $_GET['q1'];
//See notes below for username problem.
$filename = "vote.txt";
$content1 = "$v1\n";
$fp = fopen($filename, "a");
$fw = fwrite( $fp, $content1 );
fclose( $fp );
?>[/HTML]Tha code above writes to the text file. I need a way to get the username passed from vote.php to confirmation.php so i can display the name in the thanks message.
[HTML]Thank you for voting, <?php echo($user); ?>! Your vote will count. <br />
<!-- A logout link would be nice -->Click Here to log out.[/HTML]