smarty and cookies

From: Date: Mon, 10 Feb 2003 10:12:36 +0000
Subject: smarty and cookies
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-7615@lists.php.net to get a copy of this message
Hi, i'have woting system on my web site. It uses cookies to tell if someone has woted or not. I put it on my web site as an include: {php} require 'selectrazrada.php'; {/php} in smarty template or <?php require 'select.php'; ?> on other pages. when i include it on smarty templates i cant vote, cookies are not registered, like they dont exist, and when i open it on simple php everything is ok. select looks like this: <?php include 'db.php'; $sql = "SELECT * FROM anketa ORDER BY id DESC LIMIT 1"; if (($result = mysql_query($sql)) === FALSE){ echo "MySQL Error: ".mysql_error()." \n"; die(); } while ($myrow = mysql_fetch_array($result)){ $title = $myrow[title]; $naslov = $myrow[id]; }; if (($HTTP_COOKIE_VARS["Poll"] == $naslov) OR ($HTTP_COOKIE_VARS["Results"] == $naslov)) { echo '<table width="150" border="0" cellpadding="0" cellspacing="0" bgcolor="#A8C4E5"> <form action="/write.php" method="post" name="kjl">'; $sql = "SELECT * FROM anketa ORDER BY id desc LIMIT 1"; if (($result = mysql_query($sql)) === FALSE){ echo "MySQL Error: ".mysql_error()." \n"; die(); } while ($myrow = mysql_fetch_array($result)){ $myrow[title] = stripslashes($myrow[title]); echo ' <tr> <td><img src="/html/images/blokovi/anketatopr.gif" width="156" height="31"></td> </tr> <tr> <td class="textBijeli"><br><strong>&nbsp;'.$myrow[title].'</strong></td> </tr> <tr>
    <td><img src="" width="1" height="5"></td>
</tr>'; }; $sql2 = "SELECT number FROM anketa_rezultati WHERE title='$naslov' ORDER BY number DESC"; if (($result2 = mysql_query($sql2)) === FALSE){ echo "MySQL Error: ".mysql_error()." \n"; die(); } $all = "0"; while ($myrow = mysql_fetch_array($result2)){ $all = $all + $myrow[number]; }; $sql2 = "SELECT * FROM anketa_rezultati WHERE title='$naslov' ORDER BY number DESC"; if (($result2 = mysql_query($sql2)) === FALSE){ echo "MySQL Error: ".mysql_error()." \n"; die(); } echo ' <tr><td> '; while ($myrow = mysql_fetch_array($result2)){ if ($all != "" OR "0") { $number = $myrow[number] / $all; }; $number = substr($number, 0, 5); $number = $number * 100; $number2 = 100 - $number; $myrow[content] = stripslashes($myrow[content]); echo '<tr><td><font color="ffffff" face="Verdana" size="1">&nbsp;'.$myrow[content].'<br>&nbsp;<img src="/html/images/anketa1.gif" width="'.$number.'" height="8"><img src="/html/images/anketa2.gif" width="'.$number2.'" height="8">&nbsp;&nbsp;<b>'.$number.'</b>%</font></td></tr>'; }; echo ' <tr>
    <td><img src="" width="1" height="9"></td>
</tr> <tr><td><font color="ffffff" face="Verdana" size="1">&nbsp;Ukupno <b>'.$all.'</b> glasova.<br></font></td></tr> <tr>
    <td><img src="" width="1" height="5"></td>
</tr>'; if ($HTTP_COOKIE_VARS["Results"] == $naslov) { echo ' <tr>
    <td><div align="center"><input name="nazad" type="image" src="/html/images/btnglasaj.gif" width="60" height="19" border="0"></div></td>
</tr>'; }; echo '<tr> <td colspan="4"><img src="/html/images/blokovi/blokdoleanketar.gif" width="156"></td> </tr></form></table> '; } else { $title = stripslashes($title); echo '<table width="150" border="0" cellpadding="0" cellspacing="0" bgcolor="#A8C4E5"><form action="/write1.php" method="post" name="kjl"> <tr> <td><img src="/html/images/blokovi/anketatopr.gif" width="156" height="31"></td> </tr> <tr> <td class="textBijeli"><br><strong>&nbsp;'.$title.'</strong></td> </tr>'; $sql2 = "SELECT * FROM anketa_rezultati WHERE title='$naslov' ORDER BY id ASC"; if (($result2 = mysql_query($sql2)) === FALSE){ echo "MySQL Error: ".mysql_error()." \n"; die(); } echo ' '; while ($myrow = mysql_fetch_array($result2)){ $myrow[content] = stripslashes($myrow[content]); echo '<tr> <td class="textBijeli"><input type="radio" name="id" value="'.$myrow[id].'"> '.$myrow[content].'</td> </tr>'; }; echo ' <tr>
    <td><div align="center"><br><input name="glasaj" type="image" src="/html/images/btnglasaj.gif" width="60" height="19" border="0">&nbsp;&nbsp;<input name="rezultat" type="image" src="/html/images/btnrezultati.gif" width="66" height="19" border="0"></div></td>
</tr> <tr>
    <td><img src="/html/images/blokovi/blokdoleanketar.gif" width="156"></td>
</tr></form> </table>'; }; ?>

« previous php.smarty.general (#7615) next »