Page 1 of 2

Newbie need help about PHP poll code

Posted: Mon Jan 12, 2004 8:03 am
by pido
Ok first of all i got this PHP script from site for free :mrgreen: ... its script for adding poll section in my site, but i have a problem when trying to open the page, here are the script.
i put

Code: Select all

<? include poll.php ?>       //i put it in index.php in the same folder
the problems are when i click vote its not showing the result and when i open admin.php it showing this errors

Notice: Undefined variable: action in root\poll\admin.php on line 21
Notice: Undefined index: username in root\poll\admin.php on line 28
Notice: Undefined index: password in root\poll\admin.php on line 29

i tried to figure it out but i got pain in my head... so anyone can help me ?? thnx neway!!

Posted: Mon Jan 12, 2004 8:09 am
by Pyrite
<? include("poll.php"); ?>

Not sure if the case matters.

 

Posted: Mon Jan 12, 2004 8:15 am
by pido
oopz... i forgot to put double quote, ok it should be like this

Code: Select all

<? include "poll.php"; ?>
i think the problem is not in the index ... :roll:

Posted: Mon Jan 12, 2004 8:23 am
by Pyrite
May be the extra "<?" at the top of admin.php is the bug?

hmm...

Posted: Mon Jan 12, 2004 8:33 am
by pido
well... i did it again, its not supposed to be there, i think wait leme see the file.... yup its not there so its just my mistake when i copy pasted them.
thnx neway !
ohh just for note im using xp platform

Posted: Mon Jan 12, 2004 8:54 pm
by Pyrite
Why not post the refering code for admin.php ?

May be this poll script requires globals on and you have it off?

Posted: Tue Jan 13, 2004 2:04 pm
by pido
question !! how u make variables into global ???
i look in my phpinfo register_globals is ON, is that what you mean ??

Posted: Tue Jan 13, 2004 2:09 pm
by AVATAr
Undefined index: means that you are refering an array key that doesnt exists..

$arr = array(1,2,3);
echo $arr[5]; //<-- will give that notice

all that if the error_reporting level is set to show notices.

Posted: Tue Jan 13, 2004 3:17 pm
by Sarok
post your code from admin.php , and it will be easier to help.

Posted: Tue Jan 13, 2004 3:41 pm
by pido
actualy i already posted it in link, here are the code LINK, but if you want the code for admin.php i'll show you.

Code: Select all

<?
session_start();
header("Cache-control: private"); // IE 6 Fix.
include ("config.php");
?>

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link rel="stylesheet" href="css.css" type="text/css">
<title>Admin Control Panel - CJ Dynamic Poll V1.0</title>
</head>
<body topmargin="50" leftmargin="50">
<IMG SRC="top.gif" WIDTH="300" HEIGHT="81" BORDER="0" ALT="CJ Dynamic Poll"><p>

<?

$redirectscript = "<SCRIPT LANGUAGE="JavaScript">window.location="$PHP_SELF";</script>\n<noscript><A HREF="$PHP_SELF">Continue...</A></noscript>";

if ($action == "logout")&#123;
session_destroy();
echo "$redirectscript";
&#125;
http://aoi.servehttp.com/forum/profile.php?mode=register
include ("poll.txt");

$u = $_POST&#1111;'username'];
$p = $_POST&#1111;'password'];

if ($u == $admin_username && $p == $admin_password) &#123;
session_register("valid_admin");
echo "$redirectscript";
&#125;

if (session_is_registered("valid_admin")) &#123;

if ($action == "update")&#123;

if ($admin_ask == "") &#123;
echo "You did not fill in a question!<br><A HREF="javascript:history.back()">Go back</A>";
&#125;
else if ($admin_sort == "")&#123;
echo "You did not select a poll option<br><A HREF="javascript:history.back()">Go back</A>";
&#125;
else if ($admin_answer&#1111;0] == "")&#123;
echo "First answer must be entered in first answer box<br><A HREF="javascript:history.back()">Go back</A>";
&#125;
else &#123;

if ($admin_sort == "close") &#123;

$file = fopen("poll.txt","w+");

fputs ($file, "<?\n");
fputs ($file, "\$answer&#1111;0] = "";\n");
fputs ($file, "\$answer&#1111;1] = "";\n");
fputs ($file, "\$answer&#1111;2] = "";\n");
fputs ($file, "\$answer&#1111;3] = "";\n");
fputs ($file, "\$answer&#1111;4] = "";\n");
fputs ($file, "\$answer&#1111;5] = "";\n");
fputs ($file, "\$answer&#1111;6] = "";\n");
fputs ($file, "\$answer&#1111;7] = "";\n");
fputs ($file, "\$answer&#1111;8] = "";\n");
fputs ($file, "\$answer&#1111;9] = "";\n\n");

fputs ($file, "\$votes&#1111;0] = "";\n");
fputs ($file, "\$votes&#1111;1] = "";\n");
fputs ($file, "\$votes&#1111;2] = "";\n");
fputs ($file, "\$votes&#1111;3] = "";\n");
fputs ($file, "\$votes&#1111;4] = "";\n");
fputs ($file, "\$votes&#1111;5] = "";\n");
fputs ($file, "\$votes&#1111;6] = "";\n");
fputs ($file, "\$votes&#1111;7] = "";\n");
fputs ($file, "\$votes&#1111;8] = "";\n");
fputs ($file, "\$votes&#1111;9] = "";\n\n");

fputs ($file, "\$total = "";\n");
fputs ($file, "\$ask = "";\n");
fputs ($file, "?>");

fclose ($file);

echo "$redirectscript";

&#125;

else if ($admin_sort == "archive") &#123;

include("poll.txt");

$file = fopen("archive.php","a");

fputs ($file, "<font size="3">Poll Question: <b>$ask</b></font><br>Total Votes: <b>$total</b><br><br>\n");
fputs ($file, " <table border="0" cellspacing="0" width="100%">\n");

for ($i = 0; $i < count($answer); $i++) &#123;

if ($answer&#1111;$i] == "" && $votes&#1111;$i] == "")&#123;
// do nothing
&#125;
else&#123;

$percentage = (round(($votes&#1111;$i] / $total) * 100, 1));
$width = (round(($votes&#1111;$i] / $total) * 100, 0));

$img = "<img alt="$answer&#1111;$i] - $votes&#1111;$i] votes ($percentage%)" style="border: 1 solid #000000" src=$imgurl height=5 width=$width">";

fputs ($file, "<tr><td width="10%"><b>$votes&#1111;$i]</b></td>\n<td width ="45%">$answer&#1111;$i] ($percentage%)</td>\n<td width="45%">$img</td>\n</tr>\n");
&#125;

&#125;

fputs ($file, "</table><hr>\n\n");


fclose ($file);

$file2 = fopen("poll.txt","w+");

fputs ($file2, "<?\n");
fputs ($file2, "\$answer&#1111;0] = "";\n");
fputs ($file2, "\$answer&#1111;1] = "";\n");
fputs ($file2, "\$answer&#1111;2] = "";\n");
fputs ($file2, "\$answer&#1111;3] = "";\n");
fputs ($file2, "\$answer&#1111;4] = "";\n");
fputs ($file2, "\$answer&#1111;5] = "";\n");
fputs ($file2, "\$answer&#1111;6] = "";\n");
fputs ($file2, "\$answer&#1111;7] = "";\n");
fputs ($file2, "\$answer&#1111;8] = "";\n");
fputs ($file2, "\$answer&#1111;9] = "";\n\n");

fputs ($file2, "\$votes&#1111;0] = "";\n");
fputs ($file2, "\$votes&#1111;1] = "";\n");
fputs ($file2, "\$votes&#1111;2] = "";\n");
fputs ($file2, "\$votes&#1111;3] = "";\n");
fputs ($file2, "\$votes&#1111;4] = "";\n");
fputs ($file2, "\$votes&#1111;5] = "";\n");
fputs ($file2, "\$votes&#1111;6] = "";\n");
fputs ($file2, "\$votes&#1111;7] = "";\n");
fputs ($file2, "\$votes&#1111;8] = "";\n");
fputs ($file2, "\$votes&#1111;9] = "";\n\n");

fputs ($file2, "\$total = "";\n");
fputs ($file2, "\$ask = "";\n");
fputs ($file2, "?>");

fclose ($file2);

echo "$redirectscript";

&#125;


elseif ($admin_sort == "update") &#123;

$file = fopen("poll.txt","w+");

fputs ($file, "<?\n");
fputs ($file, "\$answer&#1111;0] = "$admin_answer&#1111;0]";\n");
fputs ($file, "\$answer&#1111;1] = "$admin_answer&#1111;1]";\n");
fputs ($file, "\$answer&#1111;2] = "$admin_answer&#1111;2]";\n");
fputs ($file, "\$answer&#1111;3] = "$admin_answer&#1111;3]";\n");
fputs ($file, "\$answer&#1111;4] = "$admin_answer&#1111;4]";\n");
fputs ($file, "\$answer&#1111;5] = "$admin_answer&#1111;5]";\n");
fputs ($file, "\$answer&#1111;6] = "$admin_answer&#1111;6]";\n");
fputs ($file, "\$answer&#1111;7] = "$admin_answer&#1111;7]";\n");
fputs ($file, "\$answer&#1111;8] = "$admin_answer&#1111;8]";\n");
fputs ($file, "\$answer&#1111;9] = "$admin_answer&#1111;9]";\n\n");

if ($answer&#1111;0] == "" AND $admin_answer&#1111;0] != "") &#123; fputs ($file, "\$votes&#1111;0] = "0";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;0] = "$votes&#1111;0]";\n"); &#125;

if ($answer&#1111;1] == "" AND $admin_answer&#1111;1] != "") &#123; fputs ($file, "\$votes&#1111;1] = "0";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;1] = "$votes&#1111;1]";\n"); &#125;

if ($answer&#1111;2] == "" AND $admin_answer&#1111;2] != "") &#123; fputs ($file, "\$votes&#1111;2] = "0";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;2] = "$votes&#1111;2]";\n"); &#125;

if ($answer&#1111;3] == "" AND $admin_answer&#1111;3] != "") &#123; fputs ($file, "\$votes&#1111;3] = "0";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;3] = "$votes&#1111;3]";\n"); &#125;

if ($answer&#1111;4] == "" AND $admin_answer&#1111;4] != "") &#123; fputs ($file, "\$votes&#1111;4] = "0";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;4] = "$votes&#1111;4]";\n"); &#125;

if ($answer&#1111;5] == "" AND $admin_answer&#1111;5] != "") &#123; fputs ($file, "\$votes&#1111;5] = "0";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;5] = "$votes&#1111;5]";\n"); &#125;

if ($answer&#1111;6] == "" AND $admin_answer&#1111;6] != "") &#123; fputs ($file, "\$votes&#1111;6] = "0";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;6] = "$votes&#1111;6]";\n"); &#125;

if ($answer&#1111;7] == "" AND $admin_answer&#1111;7] != "") &#123; fputs ($file, "\$votes&#1111;7] = "0";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;7] = "$votes&#1111;7]";\n"); &#125;

if ($answer&#1111;8] == "" AND $admin_answer&#1111;8] != "") &#123; fputs ($file, "\$votes&#1111;8] = "0";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;8] = "$votes&#1111;8]";\n"); &#125;

if ($answer&#1111;9] == "" AND $admin_answer&#1111;9] != "") &#123; fputs ($file, "\$votes&#1111;9] = "0";\n\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;9] = "$votes&#1111;9]";\n\n"); &#125;


fputs ($file, "\$total = "$total";\n");
fputs ($file, "\$ask = "$admin_ask";\n");
fputs ($file, "?>");

fclose ($file);

echo "$redirectscript";

&#125;

elseif ($admin_sort == "new") &#123;

$file = fopen("poll.txt","w+");


fputs ($file, "<?\n");
fputs ($file, "\$answer&#1111;0] = "$admin_answer&#1111;0]";\n");
fputs ($file, "\$answer&#1111;1] = "$admin_answer&#1111;1]";\n");
fputs ($file, "\$answer&#1111;2] = "$admin_answer&#1111;2]";\n");
fputs ($file, "\$answer&#1111;3] = "$admin_answer&#1111;3]";\n");
fputs ($file, "\$answer&#1111;4] = "$admin_answer&#1111;4]";\n");
fputs ($file, "\$answer&#1111;5] = "$admin_answer&#1111;5]";\n");
fputs ($file, "\$answer&#1111;6] = "$admin_answer&#1111;6]";\n");
fputs ($file, "\$answer&#1111;7] = "$admin_answer&#1111;7]";\n");
fputs ($file, "\$answer&#1111;8] = "$admin_answer&#1111;8]";\n");
fputs ($file, "\$answer&#1111;9] = "$admin_answer&#1111;9]";\n\n");

if ($admin_answer&#1111;0] == "") &#123; fputs ($file, "\$votes&#1111;0] = "";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;0] = "0";\n"); &#125;

if ($admin_answer&#1111;1] == "") &#123; fputs ($file, "\$votes&#1111;1] = "";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;1] = "0";\n"); &#125;

if ($admin_answer&#1111;2] == "") &#123; fputs ($file, "\$votes&#1111;2] = "";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;2] = "0";\n"); &#125;

if ($admin_answer&#1111;3] == "") &#123; fputs ($file, "\$votes&#1111;3] = "";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;3] = "0";\n"); &#125;

if ($admin_answer&#1111;4] == "") &#123; fputs ($file, "\$votes&#1111;4] = "";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;4] = "0";\n"); &#125;

if ($admin_answer&#1111;5] == "") &#123; fputs ($file, "\$votes&#1111;5] = "";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;5] = "0";\n"); &#125;

if ($admin_answer&#1111;6] == "") &#123; fputs ($file, "\$votes&#1111;6] = "";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;6] = "0";\n"); &#125;

if ($admin_answer&#1111;7] == "") &#123; fputs ($file, "\$votes&#1111;7] = "";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;7] = "0";\n"); &#125;

if ($admin_answer&#1111;8] == "") &#123; fputs ($file, "\$votes&#1111;8] = "";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;8] = "0";\n"); &#125;

if ($admin_answer&#1111;9] == "") &#123; fputs ($file, "\$votes&#1111;9] = "";\n\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;9] = "0";\n\n"); &#125;

fputs ($file, "\$total = "0";\n");
fputs ($file, "\$ask = "$admin_ask";\n");
fputs ($file, "?>");

fclose ($file);

echo "$redirectscript";
&#125;

&#125;

&#125;

else if ($clean == "ip") &#123;


$file = fopen("$clean.php","w+");
fputs ($file, "");
fclose ($file);

echo "$redirectscript";

&#125;

else if ($clean == "archive") &#123;


$file = fopen("archive.php","w+");
fputs ($file, "<head>\n<title>Poll Archive</title>\n");
fputs ($file, "<link rel="stylesheet" href="css.css" type="text/css">\n");
fputs ($file, "</head>\n<body>\n");
fclose ($file);

echo "$redirectscript";

&#125;
elseif ($clean == "poll") &#123;


$file = fopen("$clean.txt","w+");

fputs ($file, "<?\n");
fputs ($file, "\$answer&#1111;0] = "$answer&#1111;0]";\n");
fputs ($file, "\$answer&#1111;1] = "$answer&#1111;1]";\n");
fputs ($file, "\$answer&#1111;2] = "$answer&#1111;2]";\n");
fputs ($file, "\$answer&#1111;3] = "$answer&#1111;3]";\n");
fputs ($file, "\$answer&#1111;4] = "$answer&#1111;4]";\n");
fputs ($file, "\$answer&#1111;5] = "$answer&#1111;5]";\n");
fputs ($file, "\$answer&#1111;6] = "$answer&#1111;6]";\n");
fputs ($file, "\$answer&#1111;7] = "$answer&#1111;7]";\n");
fputs ($file, "\$answer&#1111;8] = "$answer&#1111;8]";\n");
fputs ($file, "\$answer&#1111;9] = "$answer&#1111;9]";\n\n");

if ($answer&#1111;0] == "") &#123; fputs ($file, "\$votes&#1111;0] = "";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;0] = "0";\n"); &#125;

if ($answer&#1111;1] == "") &#123; fputs ($file, "\$votes&#1111;1] = "";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;1] = "0";\n"); &#125;

if ($answer&#1111;2] == "") &#123; fputs ($file, "\$votes&#1111;2] = "";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;2] = "0";\n"); &#125;

if ($answer&#1111;3] == "") &#123; fputs ($file, "\$votes&#1111;3] = "";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;3] = "0";\n"); &#125;

if ($answer&#1111;4] == "") &#123; fputs ($file, "\$votes&#1111;4] = "";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;4] = "0";\n"); &#125;

if ($answer&#1111;5] == "") &#123; fputs ($file, "\$votes&#1111;5] = "";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;5] = "0";\n"); &#125;

if ($answer&#1111;6] == "") &#123; fputs ($file, "\$votes&#1111;6] = "";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;6] = "0";\n"); &#125;

if ($answer&#1111;7] == "") &#123; fputs ($file, "\$votes&#1111;7] = "";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;7] = "0";\n"); &#125;

if ($answer&#1111;8] == "") &#123; fputs ($file, "\$votes&#1111;8] = "";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;8] = "0";\n"); &#125;

if ($answer&#1111;9] == "") &#123; fputs ($file, "\$votes&#1111;9] = "";\n"); &#125; else &#123; fputs ($file, "\$votes&#1111;9] = "0";\n"); &#125;

fputs ($file, "\$total = "0";\n");
fputs ($file, "\$ask = "$ask";\n");
fputs ($file, "?>");

fclose ($file);

echo "$redirectscript";

&#125;

else &#123;

$date = date("l jS F, Y");

?>


<font size=2>Hey <b><? echo $adminname; ?></b> | <? echo $date; ?></font>
<p>
<table border="0" cellpadding="2" cellspacing="0" width="100%">
<tr>
<td width="1%"><img border="0" src="cp.jpg" width="50" height="50"></td>
<td width="99%"><font size=3><b>Admin Options</b></font></td>
</tr>
</table><p>

<?

echo "<li><a href=?clean=ip>Reset the IP Address'</a><br>\n";
echo "<li><a href=?clean=poll>Set Current Poll votes to 0</a><br>\n";
echo "<li><a href=?clean=archive>Reset Poll Archive <font color=red>(warning: existing data will be lost)</font></a><br>\n";
echo "<li><a href=archive.php>View Poll Archive</a><br>\n";
echo "<li><a href=poll.php>Back to Poll</a><br>\n\n";
echo "<li><font color=red><a href=?action=logout>Logout</a></font><br><br>\n\n";

echo "</td>\n";
echo " </tr>\n";
echo " </table>\n";

echo "<table cellpadding=0 cellspacing=0 border=0>\n";
echo "<form action=?action=update method=post>\n";
echo "<tr><td>Question<br><br></td>\n";

echo " <td>&nbsp;<input size=30 type=text name=admin_ask value="$ask"> $total<br><br></td></tr>\n";

echo "<tr><td>Answer 1: </td>\n";

echo " <td>&nbsp;<input size=30 type=text name=admin_answer&#1111;0] value="$answer&#1111;0]"> $votes&#1111;0]</td></tr>\n";

echo "<tr><td>Answer 2: </td>\n";

echo " <td>&nbsp;<input size=30 type=text name=admin_answer&#1111;1] value="$answer&#1111;1]"> $votes&#1111;1]</td></tr>\n";

echo "<tr><td>Answer 3: </td>\n";

echo " <td>&nbsp;<input size=30 type=text name=admin_answer&#1111;2] value="$answer&#1111;2]"> $votes&#1111;2]</td></tr>\n";

echo "<tr><td>Answer 4: </td>\n";

echo " <td>&nbsp;<input size=30 type=text name=admin_answer&#1111;3] value="$answer&#1111;3]"> $votes&#1111;3]</td></tr>\n";

echo "<tr><td>Answer 5: </td>\n";

echo " <td>&nbsp;<input size=30 type=text name=admin_answer&#1111;4] value="$answer&#1111;4]"> $votes&#1111;4]</td></tr>\n";

echo "<tr><td>Answer 6: </td>\n";

echo " <td>&nbsp;<input size=30 type=text name=admin_answer&#1111;5] value="$answer&#1111;5]"> $votes&#1111;5]</td></tr>\n";

echo "<tr><td>Answer 7: </td>\n";

echo " <td>&nbsp;<input size=30 type=text name=admin_answer&#1111;6] value="$answer&#1111;6]"> $votes&#1111;6]</td></tr>\n";

echo "<tr><td>Answer 8: </td>\n";

echo " <td>&nbsp;<input size=30 type=text name=admin_answer&#1111;7] value="$answer&#1111;7]"> $votes&#1111;7]</td></tr>\n";

echo "<tr><td>Answer 9: </td>\n";

echo " <td>&nbsp;<input size=30 type=text name=admin_answer&#1111;8] value="$answer&#1111;8]"> $votes&#1111;8]</td></tr>\n";

echo "<tr><td>Answer 10: </td>\n";

echo " <td>&nbsp;<input size=30 type=text name=admin_answer&#1111;9] value="$answer&#1111;9]"> $votes&#1111;9]</td></tr>\n";

echo "</table>\n\n";

?>

<br><table border="0" cellpadding="5" cellspacing="0" width="100%">
<tr>
<td width="1%"><img border="0" src="options.jpg" width="50" height="50"></td>
<td width="99%"><font size="3"><b>Poll Options</b></font></td>
</tr>
</table>
<br>

<?

echo "<table cellpadding=0 cellspacing=0 border=0><tr>\n";

echo "<td><input type=radio name=admin_sort value=new></td><td> Start new poll with above information</td></tr>\n";

echo "<tr><td><input type=radio name=admin_sort value=update></td><td> Update existing poll with above information</td></tr>\n";

echo "<tr><td><input type=radio name=admin_sort value=archive></td><td> Archive existing poll <font color=red>(note: poll will close)</font></td></tr>\n";

echo "<tr><td><input type=radio name=admin_sort value=close></td><td> Close the existing poll <font color=red>(warning: data will be lost)</font></td></tr></table>\n\n";

echo "<br><input type=submit value="Update!">";


&#125; &#125;

else &#123;

?>

<table border="0" cellpadding="5" cellspacing="0" width="100%">
<tr>
<td width="1%"><img border="0" src="login.jpg" width="50" height="50"></td>
<td width="99%"><font size="3">Admin Login</font></td>
</tr>
</table>
<br>
Login <? echo $adminname; ?>:<br><br>
<table cellpadding=5 cellspacing=0 border=0 width=200>
<form method=post>
<tr>
<td>
Username:
</td>
<td>
<input type=text name=username size="22">
</td>
</tr>
<tr>
<td valign="top">
Password:
</td>
<td>
<input type=password name=password size="22">
<center><br>
<input type=submit value="Enter Admin Area"></center>
</td>
</tr>
</table>
</form>

<?

&#125;

?>

<p><p>
</BODY>
</HTML>

Posted: Tue Jan 13, 2004 6:29 pm
by Sarok
The errors you are getting, is as AVATAr is saying, you are refering to undefined variables. One way to fix this is to use [php_man]empty[/php_man] in an if statement. As in:

Code: Select all

<?php

if (!empty($action) AND $action == 'logout') 
{

     echo 'Do stuff here.';

}

?>

Posted: Tue Jan 13, 2004 7:15 pm
by pido
Thnx for your help Sarok it really works... but how i fix the Undefined index, ok i put the code like this

Code: Select all

$u = $_POST&#1111;'username'];
$p = $_POST&#1111;'password'];

if ($u == $admin_username && $p == $admin_password) &#123;
   echo 'Do stuff';
&#125;
there are 2 errors Undefined index for $u and $p.

oh btw the big problem is in poll.php, when i voted its not go to result page but still in the same page i tried to figure this out and read all the code.. is it rite the problem is in this code

Code: Select all

echo "<SCRIPT LANGUAGE="JavaScript">window.location="$PHP_SELF";</script>\n<noscript><A HREF="$PHP_SELF">Continue...</A></noscript>";
wat is $PHP_SELF do ??

Posted: Tue Jan 13, 2004 7:39 pm
by pido
finnaly.... :D i change the code into

Code: Select all

$u = (!empty($_POST&#1111;'username']));
$p = (!empty($_POST&#1111;'password']));
but still don't know 'bout how to go to result after i click the vote button :cry:

Posted: Wed Jan 14, 2004 1:54 pm
by Sarok
$_SERVER['PHP_SELF'], or as it is in your script, $PHP_SELF is a var cotaining a string with the current file's location.

I havent read your entire script, havent got the time, but try to change $PHP_SELF to $_SERVER['PHP_SELF'].

Also, if you can get up a link with your script in action it would help greatly

Posted: Thu Jan 15, 2004 3:02 pm
by pido
its not work either it sayz
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING