hi i've just implemented a php script for a poll into my webpage, but the thing is the poll is on the out side of the iframe so when some one adds an entry the whole webpage comes into the iframe including the results, what i want is just the results to be in the iframe, i was trying to find something with target="main" but i'm new with php so can someone have a look at the script and c if they can alter it:
<style>
TD {font-family: Arial; font-size: 10pt;}
DIV {font-family: Arial; font-size: 9pt;}
TH {font-family: Arial; font-size: 10pt;}
</style>
<?php
$ip = getenv(REMOTE_ADDR);
$RESULT_FILE_NAME = "poll_data.txt";
$que = "question.txt";
$ans = "ans.txt";
$fn = fopen ($que, "r");
$puff = fread ($fn, filesize($que));
fclose ($fn);
$QUESTION = "$puff";
$lis= 0;
$plsr = file("ans.txt");
for($x=0;$x<sizeof($plsr);$x++) {
$temp = explode("|",$plsr[$x]);
$list[$lis] = $temp[0];
$lis++;
}
$ANSWER = $list;
extract($HTTP_GET_VARS);
extract($HTTP_POST_VARS);
$fname="ip_log.dat";
if (strlen($answer)<=0&&!$vresult){
echo "<FORM METHOD=\"POST\">\n";
echo "<TABLE align=center border=1 borderColor=#001199 cellPadding=2 class=normaltext style=\"BORDER-BOTTOM-COLOR: #001199; BORDER-COLLAPSE: collapse; BORDER-LEFT-COLOR: #001199; BORDER-RIGHT-COLOR: #001199; BORDER-TOP-COLOR: #001199\" >\n";
echo "<TR><TH>$QUESTION</TH></TR>\n";
while (list($key, $val) = each($ANSWER)) {
echo "<TR><TD align=\"left\"><INPUT TYPE=\"radio\" NAME=\"answer\" VALUE=\"$key\"> $val</TD></TR>\n";}
echo "<TR><TD align=\"center\"><INPUT TYPE=\"Submit\" NAME=\"vote\" VALUE=\" Vote \"></TD></TR>\n";
echo "<TR><TD align=\"center\"></form><form method=post><input type=hidden name=vresult value=1><INPUT TYPE=\"Submit\" NAME=\"result\" VALUE=\"Result\">\n";
echo "</TABLE></form>";
}
if (strlen($answer)>0) {
$plsr = file("logger.txt");
for($x=0;$x<sizeof($plsr);$x++) {
$temp = explode("|",$plsr[$x]);
}
if($ip==$temp[0] && strlen($answer)>0 ){
echo "<font color=red size=1><div align=center>You have already voted</div></font>";
$file_array = file($RESULT_FILE_NAME);
if ($answer < count($ANSWER) && $vote) {
while (list($key, $val) = each($file_array)) {
$total += $val;
}
echo "<TABLE align=center border=1 borderColor=#001199 cellPadding=2 class=normaltext style=\"BORDER-BOTTOM-COLOR: #001199; BORDER-COLLAPSE: collapse; BORDER-LEFT-COLOR: #001199; BORDER-RIGHT-COLOR: #001199; BORDER-TOP-COLOR: #001199\" width=60%>\n";
echo "<tr><th>Options</th><th>Percentage</th><th>Votes</th></tr>";
while (list($key, $val) = each($ANSWER)){
$percent = $file_array[$key] * 100 / $total;
$percent_int = floor($percent);
$percent_float = number_format($percent, 1);
$tp += $percent_float;
if($percent_int>=75){
$color="blue";
}
elseif($percent_int>=50){
$color="green";
}
elseif($percent_int>=25){
$color="orange";
}
elseif($percent_int<25){
$color="red";
}
echo "<tr><td> $ANSWER[$key] </td><td><table cellpadding=1 cellspacing=0 width=100% border=0 bgcolor=black><tr><td><table cellpadding=0 cellspacing=0 border=0 width=100%>
<tr>
<td bgcolor=$color width=$percent_int% height=10 style=border:0 >
<spacer type=block width=2 height=8>
</td>
<td bgcolor=white width=91% height=10 style=border:0 >
<spacer type=block width=2 height=8>
</td>
</tr>
</table>
</td>
</tr>
</table>$percent_float%</td><td>$file_array[$key]</td></tr>";
}
$tv=$total;
echo "<td>Total Votes: $tv</td></TABLE>";
}
}elseif (strlen($answer)>0 && $ip!=$temp[0]){
$file_array = file($RESULT_FILE_NAME);
if ($answer < count($ANSWER) && $vote) {
$old_answer = $file_array[$answer];
$old_answer = preg_replace("/\n\r*/", "", $old_answer);
$file_array[$answer] = ($old_answer + 1)."\n";
$fname="logger.txt";
$fq = fopen($fname, "a++");
fwrite ($fq, $ip);
fwrite ($fq, "|");
fwrite ($fq, "\n");
fclose ($fq);
$file = join('', $file_array);
$fp = fopen("$RESULT_FILE_NAME", "w");
flock($fp, 1);
fputs($fp, $file);
flock($fp, 3);
fclose($fp);
echo "<div align=center>Vote saved </div>";
}
while (list($key, $val) = each($file_array)) {
$total += $val;
}
echo "<TABLE align=center border=1 borderColor=#001199 cellPadding=2 class=normaltext style=\"BORDER-BOTTOM-COLOR: #001199; BORDER-COLLAPSE: collapse; BORDER-LEFT-COLOR: #001199; BORDER-RIGHT-COLOR: #001199; BORDER-TOP-COLOR: #001199\" width=60%>\n";
echo "<tr><th>Options</th><th>Percentage</th><th>Votes</th></tr>";
while (list($key, $val) = each($ANSWER)){
$percent = $file_array[$key] * 100 / $total;
$percent_int = floor($percent);
$percent_float = number_format($percent, 1);
$tp += $percent_float;
if($percent_int>=75){
$color="blue";
}
elseif($percent_int>=50){
$color="green";
}
elseif($percent_int>=25){
$color="orange";
}
elseif($percent_int<25){
$color="red";
}
echo "<tr><td> $ANSWER[$key] </td><td><table cellpadding=1 cellspacing=0 width=100% border=0 bgcolor=black><tr><td><table cellpadding=0 cellspacing=0 border=0 width=100%>
<tr>
<td bgcolor=$color width=$percent_int% height=10 style=border:0>
<spacer type=block width=2 height=8>
</td>
<td bgcolor=white width=91% height=10 style=border:0>
<spacer type=block width=2 height=8>
</td>
</tr>
</table>
</td>
</tr>
</table>$percent_float%</td><td>$file_array[$key]</td></tr>";
}
$tv=$total;
echo "<td>Total Votes: $tv</td></TABLE>";
}
else {
echo "Please Select an option first";
}
}
if (!empty ($vresult)){
$file_array = file($RESULT_FILE_NAME);
while (list($key, $val) = each($file_array)) {
$total += $val;
}
echo "<TABLE align=center border=1 borderColor=#001199 cellPadding=2 class=normaltext style=\"BORDER-BOTTOM-COLOR: #001199; BORDER-COLLAPSE: collapse; BORDER-LEFT-COLOR: #001199; BORDER-RIGHT-COLOR: #001199; BORDER-TOP-COLOR: #001199\" width=60%>\n";
echo "<tr><th>Options</th><th>Percentage</th><th>Votes</th></tr>";
while (list($key, $val) = each($ANSWER)){
$percent = $file_array[$key] * 100 / $total;
$percent_int = floor($percent);
$percent_float = number_format($percent, 1);
$tp += $percent_float;
if($percent_int>=75){
$color="blue";
}
elseif($percent_int>=50){
$color="green";
}
elseif($percent_int>=25){
$color="orange";
}
elseif($percent_int<25){
$color="red";
}
echo "<tr><td> $ANSWER[$key] </td><td><table cellpadding=1 cellspacing=0 width=100% border=0 bgcolor=black><tr><td><table cellpadding=0 cellspacing=0 border=0 width=100%>
<tr>
<td bgcolor=$color width=$percent_int% height=10 style=border:0 >
<spacer type=block width=2 height=8>
</td>
<td bgcolor=white width=91% height=10 style=border:0 >
<spacer type=block width=2 height=8>
</td>
</tr>
</table>
</td>
</tr>
</table>$percent_float%</td><td>$file_array[$key]</td></tr>";
}
$tv=$total;
echo "<td>Total Votes: $tv</td></TABLE>";
}
echo "";
?>
thanks in advanced!if it helps here is the underconstruction webpage to try it urself just so you know what i mean:
<!-- m --><a class="postlink" href="http://www.soislam.com/test/soislam-new.php">http://www.soislam.com/test/soislam-new.php</a><!-- m -->
no braggin but this page took me 2 hours to make in photoshop I wouldn't brag either. you spelt the main graphic wrong.
so, the reason you are having problems is because you are loading the whole page in the iframe. you need to load the part you want. but after voting it still doesn't tell me that I voted. so take the target out and just reload the whole page.
you might also have to split that page up to get just the results in the iframe.
<style>
TD {font-family: Arial; font-size: 10pt;}
DIV {font-family: Arial; font-size: 9pt;}
TH {font-family: Arial; font-size: 10pt;}
</style>
<?php
$ip = getenv(REMOTE_ADDR);
$RESULT_FILE_NAME = "poll_data.txt";
$que = "question.txt";
$ans = "ans.txt";
$fn = fopen ($que, "r");
$puff = fread ($fn, filesize($que));
fclose ($fn);
$QUESTION = "$puff";
$lis= 0;
$plsr = file("ans.txt");
for($x=0;$x<sizeof($plsr);$x++) {
$temp = explode("|",$plsr[$x]);
$list[$lis] = $temp[0];
$lis++;
}
$ANSWER = $list;
extract($HTTP_GET_VARS);
extract($HTTP_POST_VARS);
$fname="ip_log.dat";
if (strlen($answer)<=0&&!$vresult){
echo "<FORM METHOD=\"POST\">\n";
echo "<TABLE align=center border=1 borderColor=#001199 cellPadding=2 class=normaltext style=\"BORDER-BOTTOM-COLOR: #001199; BORDER-COLLAPSE: collapse; BORDER-LEFT-COLOR: #001199; BORDER-RIGHT-COLOR: #001199; BORDER-TOP-COLOR: #001199\" >\n";
echo "<TR><TH>$QUESTION</TH></TR>\n";
while (list($key, $val) = each($ANSWER)) {
echo "<TR><TD align=\"left\"><INPUT TYPE=\"radio\" NAME=\"answer\" VALUE=\"$key\"> $val</TD></TR>\n";}
echo "<TR><TD align=\"center\"><INPUT TYPE=\"Submit\" NAME=\"vote\" VALUE=\" Vote \"></TD></TR>\n";
echo "<TR><TD align=\"center\"></form><form method=post><input type=hidden name=vresult value=1><INPUT TYPE=\"Submit\" NAME=\"result\" VALUE=\"Result\">\n";
echo "</TABLE></form>";
}
if (strlen($answer)>0) {
$plsr = file("logger.txt");
for($x=0;$x<sizeof($plsr);$x++) {
$temp = explode("|",$plsr[$x]);
}
if($ip==$temp[0] && strlen($answer)>0 ){
echo "<font color=red size=1><div align=center>You have already voted</div></font>";
$file_array = file($RESULT_FILE_NAME);
if ($answer < count($ANSWER) && $vote) {
while (list($key, $val) = each($file_array)) {
$total += $val;
}
echo "<TABLE align=center border=1 borderColor=#001199 cellPadding=2 class=normaltext style=\"BORDER-BOTTOM-COLOR: #001199; BORDER-COLLAPSE: collapse; BORDER-LEFT-COLOR: #001199; BORDER-RIGHT-COLOR: #001199; BORDER-TOP-COLOR: #001199\" width=60%>\n";
echo "<tr><th>Options</th><th>Percentage</th><th>Votes</th></tr>";
while (list($key, $val) = each($ANSWER)){
$percent = $file_array[$key] * 100 / $total;
$percent_int = floor($percent);
$percent_float = number_format($percent, 1);
$tp += $percent_float;
if($percent_int>=75){
$color="blue";
}
elseif($percent_int>=50){
$color="green";
}
elseif($percent_int>=25){
$color="orange";
}
elseif($percent_int<25){
$color="red";
}
echo "<tr><td> $ANSWER[$key] </td><td><table cellpadding=1 cellspacing=0 width=100% border=0 bgcolor=black><tr><td><table cellpadding=0 cellspacing=0 border=0 width=100%>
<tr>
<td bgcolor=$color width=$percent_int% height=10 style=border:0 >
<spacer type=block width=2 height=8>
</td>
<td bgcolor=white width=91% height=10 style=border:0 >
<spacer type=block width=2 height=8>
</td>
</tr>
</table>
</td>
</tr>
</table>$percent_float%</td><td>$file_array[$key]</td></tr>";
}
$tv=$total;
echo "<td>Total Votes: $tv</td></TABLE>";
}
}elseif (strlen($answer)>0 && $ip!=$temp[0]){
$file_array = file($RESULT_FILE_NAME);
if ($answer < count($ANSWER) && $vote) {
$old_answer = $file_array[$answer];
$old_answer = preg_replace("/\n\r*/", "", $old_answer);
$file_array[$answer] = ($old_answer + 1)."\n";
$fname="logger.txt";
$fq = fopen($fname, "a++");
fwrite ($fq, $ip);
fwrite ($fq, "|");
fwrite ($fq, "\n");
fclose ($fq);
$file = join('', $file_array);
$fp = fopen("$RESULT_FILE_NAME", "w");
flock($fp, 1);
fputs($fp, $file);
flock($fp, 3);
fclose($fp);
echo "<div align=center>Vote saved </div>";
}
while (list($key, $val) = each($file_array)) {
$total += $val;
}
echo "<TABLE align=center border=1 borderColor=#001199 cellPadding=2 class=normaltext style=\"BORDER-BOTTOM-COLOR: #001199; BORDER-COLLAPSE: collapse; BORDER-LEFT-COLOR: #001199; BORDER-RIGHT-COLOR: #001199; BORDER-TOP-COLOR: #001199\" width=60%>\n";
echo "<tr><th>Options</th><th>Percentage</th><th>Votes</th></tr>";
while (list($key, $val) = each($ANSWER)){
$percent = $file_array[$key] * 100 / $total;
$percent_int = floor($percent);
$percent_float = number_format($percent, 1);
$tp += $percent_float;
if($percent_int>=75){
$color="blue";
}
elseif($percent_int>=50){
$color="green";
}
elseif($percent_int>=25){
$color="orange";
}
elseif($percent_int<25){
$color="red";
}
echo "<tr><td> $ANSWER[$key] </td><td><table cellpadding=1 cellspacing=0 width=100% border=0 bgcolor=black><tr><td><table cellpadding=0 cellspacing=0 border=0 width=100%>
<tr>
<td bgcolor=$color width=$percent_int% height=10 style=border:0>
<spacer type=block width=2 height=8>
</td>
<td bgcolor=white width=91% height=10 style=border:0>
<spacer type=block width=2 height=8>
</td>
</tr>
</table>
</td>
</tr>
</table>$percent_float%</td><td>$file_array[$key]</td></tr>";
}
$tv=$total;
echo "<td>Total Votes: $tv</td></TABLE>";
}
else {
echo "Please Select an option first";
}
}
if (!empty ($vresult)){
$file_array = file($RESULT_FILE_NAME);
while (list($key, $val) = each($file_array)) {
$total += $val;
}
echo "<TABLE align=center border=1 borderColor=#001199 cellPadding=2 class=normaltext style=\"BORDER-BOTTOM-COLOR: #001199; BORDER-COLLAPSE: collapse; BORDER-LEFT-COLOR: #001199; BORDER-RIGHT-COLOR: #001199; BORDER-TOP-COLOR: #001199\" width=60%>\n";
echo "<tr><th>Options</th><th>Percentage</th><th>Votes</th></tr>";
while (list($key, $val) = each($ANSWER)){
$percent = $file_array[$key] * 100 / $total;
$percent_int = floor($percent);
$percent_float = number_format($percent, 1);
$tp += $percent_float;
if($percent_int>=75){
$color="blue";
}
elseif($percent_int>=50){
$color="green";
}
elseif($percent_int>=25){
$color="orange";
}
elseif($percent_int<25){
$color="red";
}
echo "<tr><td> $ANSWER[$key] </td><td><table cellpadding=1 cellspacing=0 width=100% border=0 bgcolor=black><tr><td><table cellpadding=0 cellspacing=0 border=0 width=100%>
<tr>
<td bgcolor=$color width=$percent_int% height=10 style=border:0 >
<spacer type=block width=2 height=8>
</td>
<td bgcolor=white width=91% height=10 style=border:0 >
<spacer type=block width=2 height=8>
</td>
</tr>
</table>
</td>
</tr>
</table>$percent_float%</td><td>$file_array[$key]</td></tr>";
}
$tv=$total;
echo "<td>Total Votes: $tv</td></TABLE>";
}
echo "";
?>
thanks in advanced!if it helps here is the underconstruction webpage to try it urself just so you know what i mean:
<!-- m --><a class="postlink" href="http://www.soislam.com/test/soislam-new.php">http://www.soislam.com/test/soislam-new.php</a><!-- m -->
no braggin but this page took me 2 hours to make in photoshop I wouldn't brag either. you spelt the main graphic wrong.
so, the reason you are having problems is because you are loading the whole page in the iframe. you need to load the part you want. but after voting it still doesn't tell me that I voted. so take the target out and just reload the whole page.
you might also have to split that page up to get just the results in the iframe.