Strange redirect problem!
Posted: Sat Jul 12, 2003 3:35 pm
Hi everybody!
I want to redirect users from a page to one of two pages, according to the following condition:
-when a user votes on a certain item, if his/her vote already exists in the certain table from my database (table reg_votos) he is supposed to not be able to vote and go to page "VotosNotOK";
-on the other hand, if there isn't any entrance in the table of the user's IP together with the vote he/her intends to make, the user must go to "VotosOK"
For that i'm using the following code:
Now i'm dealing with this situation:
when the user can vote (i.e., it is the first time that user votes on that item) the page is correctly redirected to "VotosOK". However, when that is not the case, thus the voting page should be redirected to "VotosNotOk" page, i get this error message:
"CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:"
According to this topic of the forum - viewtopic.php?t=1157, this type of error is due to trying to send content to the browser before sending header information. Can someone explain me which content is being sent when user is supposed to go to "VotosNotOK"? And also, why it does not happen when one is redirected to the "VotosOk" page?!?
Is there any other reason why this is happening?
HELP please!
I want to redirect users from a page to one of two pages, according to the following condition:
-when a user votes on a certain item, if his/her vote already exists in the certain table from my database (table reg_votos) he is supposed to not be able to vote and go to page "VotosNotOK";
-on the other hand, if there isn't any entrance in the table of the user's IP together with the vote he/her intends to make, the user must go to "VotosOK"
For that i'm using the following code:
Code: Select all
<?php
$currentPage = $HTTP_SERVER_VARS["PHP_SELF"];
?>
<?php
$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
$id_autor=$_GET['id_autor'];
$userIP=$_SERVER['REMOTE_ADDR'];
if ((isset($HTTP_POST_VARS["MM_update"])) && ($HTTP_POST_VARS["MM_update"] == "form_rimas")) {
$procuraSQL = "SELECT COUNT(*) FROM reg_votos WHERE endIP='$userIP' AND rima='$id_autor'";
mysql_select_db($database_connRapMania, $connRapMania);
$procura = mysql_query($procuraSQL, $connRapMania) or die(mysql_error());
while ($row_resultadosProcura = mysql_fetch_assoc($procura)) {
$existe=(int)$row_resultadosProcura['COUNT(*)'];
if ($existe == 0){// vote do not exists
$updateSQL = sprintf("UPDATE rimas_00 SET pontos=pontos+%s WHERE id=%s",
GetSQLValueString($HTTP_POST_VARS['votos'], "int"),
GetSQLValueString($HTTP_POST_VARS['hiddenID'], "int"));
mysql_select_db($database_connRapMania, $connRapMania);
$Result1 = mysql_query($updateSQL, $connRapMania) or die(mysql_error());
//insert vote in database
$updateVotos = "INSERT INTO reg_votos (endIP, rima) VALUES ('$userIP', '$id_autor')";
mysql_select_db($database_connRapMania, $connRapMania);
$ResultVotos = mysql_query($updateVotos, $connRapMania) or die(mysql_error());
$updateGoTo = "votosOK.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
//header(sprintf("Location: %s", $updateGoTo));
}
else{
$updateGoTo = "votosNotOK.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
//header(sprintf("Location: %s", $updateGoTo));
}
}// end while
mysql_free_result($procura);
header(sprintf("Location: %s", $updateGoTo));
}//end if issset $HTTP
[... remaining and necessary code to display the voting page goes here..]
?>when the user can vote (i.e., it is the first time that user votes on that item) the page is correctly redirected to "VotosOK". However, when that is not the case, thus the voting page should be redirected to "VotosNotOk" page, i get this error message:
"CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:"
According to this topic of the forum - viewtopic.php?t=1157, this type of error is due to trying to send content to the browser before sending header information. Can someone explain me which content is being sent when user is supposed to go to "VotosNotOK"? And also, why it does not happen when one is redirected to the "VotosOk" page?!?
Is there any other reason why this is happening?
HELP please!