Hey everyone. I was working at a members section where the member could vote. Once I combined my script along with the voting script the page wouldn’t show anything – just whitespace. ๐ฎ
I was wondering if some of the php experts help me out! ?
Thanks,
Chris
Script:
<?php
session_register(“Email”);
if (!isset($_SESSION[‘Email’]))
{
// User not logged in, redirect to login page
Header(“Location: payments.html”);
}
//Variables for connection
$dbhost = “localhost”;
$dbname = “na032339”;
$dbuser = “na032339”;
$dbpass = “na032339”;
//Connect to database
$link_id = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname);
//Select statements
$sql = “SELECT `Title`Question`ID`poll_data`ID
if(!($result = mysql_query($sql))) die(mysql_error());
$PollData = mysql_fetch_array($result);
$sql = “SELECT `Option1`Option2`Option3`Votes`poll_data`ID`ID
if(!($result = mysql_query($sql))) die(mysql_error());
if(!($VoteData = mysql_fetch_array($result))) die(mysql_error());
//Get percent
if($VoteData[“Option1”] != 0) {
$VotePercent1 = Round(($VoteData[“Option1”] / $VoteData[“Votes”]) * 100) . “%”;
} else {
$VotePercent1 = 0 .”%”;
}
if($VoteData[“Option2”] != 0) {
$VotePercent2 = Round(($VoteData[“Option2”] / $VoteData[“Votes”])
} else {
$VotePercent2 = 0 .”%”;
}
if($VoteData[“Option3”] != 0) {
$VotePercent3 = Round(($VoteData[“Option3”] / $VoteData[“Votes”]) * 100) . “%”;
} else {
$VotePercent3 = 0 .”%”;
}
// Display Member information
echo “<p>Currently logged in as: ” . $_SESSION[“Email”];
// Display logout link
echo “<p>Not you?<a href=”logout.php”> Logout!</a></p>”;
?>
<html>
<head>
<title>Memembers Section</title>
</head>
<body>
<form method=”POST” action=”vote.php”>
<table width=”500″ border=”1″ cellspacing=”0″ cellpadding=”8″>
<tr>
<td colspan=”3″><b><?=$PollData[‘Title’]?> – <?=$PollData[‘Question’]?></b></td>
</tr>
<tr>
<td width=”35%”>
<input type=”radio” name=”Vote” value=”Option1″>
Yes</td>
<td width=60%>
<img src=”bar.gif” width=”<?=$VotePercent1?>” height=”20″>
</td>
<td><?=$VoteData[“Option1”]?> Votes</td>
</tr>
<tr>
<td width=”35%”>
<input type=”radio” name=”Vote” value=”Option2″>
No </td>
<td width=60%>
<img src=”bar.gif” width=”<?=$VotePercent2?>” height=”20″>
</td>
<td><?=$VoteData[“Option2”]?> Votes</td>
</tr>
<tr>
<td width=”35%”>
<input type=”radio” name=”Vote” value=”Option3″ >
Not Sure</td>
<td width=”60%”>
<img src=”bar.gif” width=”<?=$VotePercent3?>” height=”20″>
</td>
<td><?=$VoteData[“Option3”]?> Votes</td>
</tr>
<tr>
<td colspan=”3″>
<center>
<input type=”submit” name=”Submit” value=”Vote”>
</center>
</td>
</tr>
</table>
</form>
</body>
</html>