[PHP]WTF is wrong with my poll? (Stucked on it for 8hours)
Code:
<?php
include("config.php");
function tep_get_ip_address() {
if (isset($_SERVER)) {
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
} else {
if (getenv('HTTP_X_FORWARDED_FOR')) {
$ip = getenv('HTTP_X_FORWARDED_FOR');
} elseif (getenv('HTTP_CLIENT_IP')) {
$ip = getenv('HTTP_CLIENT_IP');
} else {
$ip = getenv('REMOTE_ADDR');
}
}
return $ip;
}
$human = $_POST['human'];
if(!isset($_POST['register'])){
echo "
<fieldset>
<legend><b>Poll</b></legend>
<center><form method=\"post\" action=''>
<table border=\"0\" width=\"150\" style=\"background-color:#EEEEEE;color:#000000;font-family:'Verdana';font-size:13px;\" cellspacing=\"0\" cellpadding=\"2\">
<tr><td colspan=\"2\" style=\"padding:2px;\"><strong>Which MMORPG Private Server below do you like to play most as of September 08 2009?</strong></td></tr>
<tr><td width=\"5\"><input type=radio name=\"answer\" value=\"muonline\"></td><td style=\"padding:2px;\">MuOnline</td></tr>
<tr><td width=\"5\"><input type=radio name=\"answer\" value=\"maplestory\"\"></td><td style=\"padding:2px;\">Maplestory</td></tr>
<tr><td colspan=\"2\"><center>
<input type=\"submit\" value=\"register\" name=\"Submit\" />
</center></td></tr>
</form>
</fieldset><br />
Please take note, your IP address is logged when you vote.";
/*Something wrong from below here eh?*/
}else
if(value == "muonline") {
$ia = mysql_query("UPDATE `votetable` SET `votes`=votes+1, WHERE `id`='1'") or die(mysql_error());
}elseif(value == "maplestory"){
$ia = mysql_query("UPDATE `votetable` SET `votes`=votes+1, WHERE `id`='2'") or die(mysql_error());
}else{
exit();
}
Well I'm total noob for this, I been trying this out on my own domain website for hours, still doesn't work. Don't know if this is consider dumping my question to people here, but I really tried for long hours.
The problem I'm having now is, this poll will never update mySQL. vote it, nothing happens,
But I'm quite certain the only problem lies with
Code:
}else
if(value == "muonline") {
$ia = mysql_query("UPDATE `votetable` SET `votes`=votes+1, WHERE `id`='1'") or die(mysql_error());
}elseif(value == "maplestory"){
$ia = mysql_query("UPDATE `votetable` SET `votes`=votes+1, WHERE `id`='2'") or die(mysql_error());
}else{
exit();
}
Can anyone correct me?
http://foxthrone.com/poll/poll.php
This poll is just a test to try things out. Not for any uses, will properly remove it after its done though, but I really wants to finish it. please help ._.
Re: [PHP]WTF is wrong with my poll? (Stucked on it for 8hours)
PHP Code:
<?
if(value == "muonline") {
$ia = mysql_query("UPDATE `votetable` SET `votes`=votes+1 WHERE `id`='1'") or die(mysql_error());
}elseif(value == "maplestory"){
$ia = mysql_query("UPDATE `votetable` SET `votes`=votes+1 WHERE `id`='2'") or die(mysql_error());
}else{
exit();
}
?>
Try that.
Re: [PHP]WTF is wrong with my poll? (Stucked on it for 8hours)
Gut that posted message above is right.
Your mistake was in this:
PHP Code:
}else
if(value == "muonline") {
you should put { after }else
Re: [PHP]WTF is wrong with my poll? (Stucked on it for 8hours)
No changes still though, I think the problem lies with the method I'm handling my radio buttons data.
Solved. Ended up googling for tutorials and ended up copy pasting their works =|
http://www.trap17.com/index.php/Php-...ts_t47026.html
Re: [PHP]WTF is wrong with my poll? (Stucked on it for 8hours)
Dam.. just missed you then:
Code:
<?php
include("config.php");
function tep_get_ip_address() {
if (isset($_SERVER)) {
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
} else {
if (getenv('HTTP_X_FORWARDED_FOR')) {
$ip = getenv('HTTP_X_FORWARDED_FOR');
} elseif (getenv('HTTP_CLIENT_IP')) {
$ip = getenv('HTTP_CLIENT_IP');
} else {
$ip = getenv('REMOTE_ADDR');
}
}
return $ip;
}
$human = $_POST['human'];
if(!isset($_POST['Submit'])){
echo "
<fieldset>
<legend><b>Poll</b></legend>
<center><form method=\"post\" action=''>
<table border=\"0\" width=\"150\" style=\"background-color:#EEEEEE;color:#000000;font-family:'Verdana';font-size:13px;\" cellspacing=\"0\" cellpadding=\"2\">
<tr><td colspan=\"2\" style=\"padding:2px;\"><strong>Which MMORPG Private Server below do you like to play most as of September 08 2009?</strong></td></tr>
<tr><td width=\"5\"><input type=radio name=\"answer\" value=\"muonline\"></td><td style=\"padding:2px;\">MuOnline</td></tr>
<tr><td width=\"5\"><input type=radio name=\"answer\" value=\"maplestory\"\"></td><td style=\"padding:2px;\">Maplestory</td></tr>
<tr><td colspan=\"2\"><center>
<input type=\"submit\" value=\"register\" name=\"Submit\"/>
</center></td></tr>
</form>
</fieldset><br />
Please take note, your IP address is logged when you vote.";
/*Something wrong from below here eh?*/
}else
if($_POST['answer'] == "muonline") {
$ia = mysql_query("UPDATE `votetable` SET `votes`=votes+1, WHERE `id`='1'") or die(mysql_error());
}elseif($_POST['answer'] == "maplestory"){
$ia = mysql_query("UPDATE `votetable` SET `votes`=votes+1, WHERE `id`='2'") or die(mysql_error());
}else{
exit();
}
that would have been the working version of what you were trying to achieve.
Re: [PHP]WTF is wrong with my poll? (Stucked on it for 8hours)
Quote:
Originally Posted by
-fedexer-
Dam.. just missed you then:
Code:
<?php
include("config.php");
function tep_get_ip_address() {
if (isset($_SERVER)) {
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
} else {
if (getenv('HTTP_X_FORWARDED_FOR')) {
$ip = getenv('HTTP_X_FORWARDED_FOR');
} elseif (getenv('HTTP_CLIENT_IP')) {
$ip = getenv('HTTP_CLIENT_IP');
} else {
$ip = getenv('REMOTE_ADDR');
}
}
return $ip;
}
$human = $_POST['human'];
if(!isset($_POST['Submit'])){
echo "
<fieldset>
<legend><b>Poll</b></legend>
<center><form method=\"post\" action=''>
<table border=\"0\" width=\"150\" style=\"background-color:#EEEEEE;color:#000000;font-family:'Verdana';font-size:13px;\" cellspacing=\"0\" cellpadding=\"2\">
<tr><td colspan=\"2\" style=\"padding:2px;\"><strong>Which MMORPG Private Server below do you like to play most as of September 08 2009?</strong></td></tr>
<tr><td width=\"5\"><input type=radio name=\"answer\" value=\"muonline\"></td><td style=\"padding:2px;\">MuOnline</td></tr>
<tr><td width=\"5\"><input type=radio name=\"answer\" value=\"maplestory\"\"></td><td style=\"padding:2px;\">Maplestory</td></tr>
<tr><td colspan=\"2\"><center>
<input type=\"submit\" value=\"register\" name=\"Submit\"/>
</center></td></tr>
</form>
</fieldset><br />
Please take note, your IP address is logged when you vote.";
/*Something wrong from below here eh?*/
}else
if($_POST['answer'] == "muonline") {
$ia = mysql_query("UPDATE `votetable` SET `votes`=votes+1, WHERE `id`='1'") or die(mysql_error());
}elseif($_POST['answer'] == "maplestory"){
$ia = mysql_query("UPDATE `votetable` SET `votes`=votes+1, WHERE `id`='2'") or die(mysql_error());
}else{
exit();
}
that would have been the working version of what you were trying to achieve.
thanks for trying to help, i had it done already though. yours works as well