The Little Guy Posted January 5, 2007 Share Posted January 5, 2007 I don't under stand why this isn't working, maybe I'm missing something I don't know:[code]<form action="http://ifolio.no-ip.org/poll/includes/poll/vote.php?poll_num=1" method="post"><input type="radio" name="1" value="Me"> Me<br><input type="radio" name="1" value="You"> You<br><br><input type="submit" name="submit" value="Vote!"></form>[/code][code]<?phpecho $_POST['1'];?>[/code]When I echo it out, nothing is outputted. Why? Quote Link to comment https://forums.phpfreaks.com/topic/33013-please-help/ Share on other sites More sharing options...
ToonMariner Posted January 5, 2007 Share Posted January 5, 2007 you can't use numbers for html vars Quote Link to comment https://forums.phpfreaks.com/topic/33013-please-help/#findComment-153750 Share on other sites More sharing options...
PFMaBiSmAd Posted January 5, 2007 Share Posted January 5, 2007 Are you sure you are selecting one of the radio buttons?I tested your code using my generic form submission/display code.No radio button selected, gives this -[code]POST data -Key: submit, Value: Vote!GET data -Key: poll_num, Value: 1[/code]Selecting the first button, gives this -[code]POST data -Key: 1, Value: MeKey: submit, Value: Vote!GET data -Key: poll_num, Value: 1[/code] Quote Link to comment https://forums.phpfreaks.com/topic/33013-please-help/#findComment-153758 Share on other sites More sharing options...
The Little Guy Posted January 5, 2007 Author Share Posted January 5, 2007 [quote author=ToonMariner link=topic=121164.msg497686#msg497686 date=1168030458]you can't use numbers for html vars[/quote]I changed it to x1, and it still doesn't work[quote author=PFMaBiSmAd link=topic=121164.msg497694#msg497694 date=1168030800]Are you sure you are selecting one of the radio buttons?I tested your code using my generic form submission/display code.No radio button selected, gives this -[code]POST data -Key: submit, Value: Vote!GET data -Key: poll_num, Value: 1[/code]Selecting the first button, gives this -[code]POST data -Key: 1, Value: MeKey: submit, Value: Vote!GET data -Key: poll_num, Value: 1[/code][/quote]Yes I'm positive. Here is the entire code to view:[code]<?php if(!isset($_SESSION['logged_in'])){ include("../db.php"); $sqll = "SELECT * FROM polls WHERE id='$_GET[poll_text]' ORDER BY name ASC"; }else{ $sqll = "SELECT * FROM polls WHERE email='$_SESSION[email]' ORDER BY name ASC"; }$resultl = mysql_query($sqll);$number = mysql_num_rows($resultl);if(!isset($_GET['poll_text'])){ if (!isset($poll_text)) { echo" What poll do you want view?<table>"; while($poll = mysql_fetch_array($resultl)){ if($htaccess == 2){ echo '<tr><td> <a href="'.$_SERVER[PHP_SELF].'?poll=view&poll_text='.$poll['id'].'">'.$poll['name'].'</a></td></tr>'; }elseif($htaccess == 1){ echo '<tr><td> <a href="'.$poll_url.'poll/'.$poll['id'].'">'.$poll['name'].'</a></td></tr>'; } } if($announcement == 1){ echo'<table> <tr> <td style="background-color:'.$announcement_color.';"><b>Announcement</b></td> </tr> <tr> <td>'; include("includes/announcement.txt"); echo'</td> </tr> </table>'; } echo"</table> <a href=\"userpage.php\">Back to main</a>"; }}else{ $code = $_GET['poll_text']; $sql = mysql_query("SELECT * FROM poll_option WHERE id='$code' ORDER BY idnum ASC"); $sqls = mysql_query("SELECT * FROM polls WHERE id='$code' ORDER BY name ASC"); $polls = mysql_fetch_array($sqls); if (!$polls){ echo'<h2>Error</h2> This poll doesn\'t exist. It may have been deleted<br>'; }else{ $numbers = mysql_num_rows($sql); if(isset($_SESSION['email'])){ echo'<b>'.$polls['name'].'</b><br>'; } echo "<b>".$polls['question']."</b><br>"; echo ' <form action="'.$poll_url.'includes/poll/vote.php?poll_num='.$polls['id'].'" method="post">'; $lett = 1; while($rows = mysql_fetch_array($sql)){ echo '<input type="radio" name="'.$rows["id"].'" value="'.$rows["option"].'"> '.$rows["option"].'<br>'; $lett++; } echo ' <br> <input type="submit" name="submit" value="Vote!"> </form>'; } if(isset($_SESSION['email'])){ if($announcement == 1){ echo'<table> <tr> <td style="background-color:'.$announcement_color.';"><b>Announcement</b></td> </tr> <tr> <td>'; include("includes/announcement.txt"); echo'</td> </tr> </table>'; } echo' <a href="'.$poll_url.'userpage.php">Back to main</a>'; } echo "<div class=\"powered\"><p>Powered By <a href=\"$poll_url\">$poll_url</a></p></div>";}?>[/code]And here is the code to print:[code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><? include('../db.php'); $sql = mysql_query("SELECT * FROM user");?><html><head><?include($poll_url.'includes/layout/style.php');?><title>Poll Hosting</title></head><body><?phpinclude($poll_url.'includes/layout/top.php');$poll_num = $_GET['poll_num'];echo $_POST['1'];/*if(!isset($_POST['submit']) || !empty($_POST['poll'.$poll_num.''])){ $ip = $_SERVER['REMOTE_ADDR']; $vote = $_POST[$poll_num]; $sql = mysql_query("select * FROM poll_option WHERE `option`='$vote' AND `id`='$poll_num'")or die(mysql_error()); $count = mysql_fetch_array($sql); $newcount = $count['count'] + 1; $results = mysql_query("SELECT * FROM ip WHERE ip='$ip' AND pollid='$poll_num'")or die(mysql_error()); if(mysql_num_rows($results) > 0){ echo "<h2>You have already voted</h2>"; $sql = mysql_query("SELECT * FROM poll_option WHERE id='$poll_num' ORDER BY idnum ASC"); $sqls = mysql_query("SELECT * FROM polls WHERE id='$poll_num' ORDER BY name ASC"); $polls = mysql_fetch_array($sqls); $numbers = mysql_num_rows($sql); echo "<b>".$polls['question']."</b>"; echo"\n<table>\n"; while($rows = mysql_fetch_array($sql)){ echo "\t<tr>\n\t\t<td>".$rows["option"]."</td><td>". $rows["count"]."</td>\n\t</tr>\n"; } echo"</table>\n"; echo "<p><a href=\"$polls[redirect]\">$polls[redirect]</a></p>"; echo "<div class=\"powered\"><p>Powered By <a href=\"$poll_url\">$poll_url</a></p></div>"; }else{ mysql_query("UPDATE poll_option SET `count`='$newcount' WHERE `option`='$vote' AND `id`='$poll_num'"); mysql_query("INSERT INTO ip(`pollid`, `ip`) VALUES('$poll_num','$ip')"); echo"<h2>Success</h2> <h3>New Results:</h3>"; $sql = mysql_query("SELECT * FROM poll_option WHERE id='$poll_num' ORDER BY idnum ASC"); $sqls = mysql_query("SELECT * FROM polls WHERE id='$poll_num' ORDER BY name ASC"); $polls = mysql_fetch_array($sqls); $numbers = mysql_num_rows($sql); echo "<b>".$polls['question']."</b>"; echo"\n<table>\n"; while($rows = mysql_fetch_array($sql)){ echo "\t<tr>\n\t\t<td>".$rows["option"]."</td><td>". $rows["count"]."</td>\n\t</tr>\n"; } echo"</table>\n"; echo "<p><a href=\"$polls[redirect]\">$polls[redirect]</a></p>"; echo "<div class=\"powered\"><p>Powered By <a href=\"$poll_url\">$poll_url</a></p></div>"; }}else{ echo"<h2>Sorry You Cant Do That</h2>";}*/?><?include($poll_url.'includes/layout/bottom.php');?></body></html>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/33013-please-help/#findComment-153780 Share on other sites More sharing options...
The Little Guy Posted January 6, 2007 Author Share Posted January 6, 2007 any help? Quote Link to comment https://forums.phpfreaks.com/topic/33013-please-help/#findComment-154017 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.