Dragoonus Posted March 4, 2005 Share Posted March 4, 2005 Im making a big vote (as you may have noticed in my other post) after managing to get the vote updating I now can't seem to get the cookies working (heh, no doubt I'll be back onces its IP time, lol) anyhoos the problem is that I am allowed to vote even if I do have the cookie. I thinks its something to do with $voteValid <?php require_once('Connections/mysql.php'); ?> <?php if( isset( $HTTP_COOKIE_VARS[ '$IVoted' ] ) ) { // cookie exists, BAD vote! $voteValid = 0; } else { $voteValid = "1"; } ?> <?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } $editFormAction = $HTTP_SERVER_VARS['PHP_SELF']; if($voteValid>0) { if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { $editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING']; } } if ((isset($HTTP_POST_VARS["MM_update"])) && ($HTTP_POST_VARS["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE poll_one SET Vote=Vote+1 WHERE lid=%s", GetSQLValueString($HTTP_POST_VARS['title'], "text"), GetSQLValueString($HTTP_POST_VARS[Vote], "int"), GetSQLValueString($HTTP_POST_VARS['lid'], "int")); mysql_select_db($database_mysql, $mysql); $Result1 = mysql_query($updateSQL, $mysql) or die(mysql_error()); $updateGoTo = "/results.php"; if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $HTTP_SERVER_VARS['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } mysql_select_db($database_mysql, $mysql); $query_Recordset1 = "SELECT * FROM poll_one"; $Recordset1 = mysql_query($query_Recordset1, $mysql) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> <?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <form method="post" name="form1" action="<?php echo $editFormAction; ?>"> <table align="center"> <tr valign="baseline"> <td nowrap align="right">Title:</td> <td> <select name="title" size="15"> <?php do { ?> <option value="<?php echo $row_Recordset1['lid']?>"><?php echo $row_Recordset1['title']?></option> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); $rows = mysql_num_rows($Recordset1); if($rows > 0) { mysql_data_seek($Recordset1, 0); $row_Recordset1 = mysql_fetch_assoc($Recordset1); } ?> </select> </td> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td><input type="submit" value="Update Record"></td> </tr> </table> <input type="hidden" name="MM_update" value="form1"> <input type="hidden" name="lid" value="<?php echo $row_Recordset1['lid']; ?>"> </form> <p> </p> </body> </html> <?php mysql_free_result($Recordset1); ?> As you can see this is just the test (hence no proper names or anything) anyhoos any help at all would be appreciated, It seems everytime I take a step forward I have to rewind to nothing 4 days later before I can take the next step... lol o btw setcookie is on another page Quote Link to comment Share on other sites More sharing options...
jesserules Posted March 12, 2005 Share Posted March 12, 2005 first of all, it's not $HTTP_COOKIE_VARS['$iVoted'], its without a dollar sign ($HTTP_COOKIE_VARS['iVoted']) unless thats what the var is called. also, i think some PHP versions would use $_COOKIES['iVoted'] or just $iVoted without anything else. im not sure if thats the problem, but i've had problems with cookies before, and i realized i had to use just the var name, without $_COOKIES or $HTTP_COOKIE_VARS. try it and see if it works. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.