hbalagh Posted August 13, 2007 Author Share Posted August 13, 2007 ok i got it to not throw any errors, how ever it doesn't automatically send them to the the results page unless you hit the submit button and after deleteing my ip from the db it doesn't add the new votes in Quote Link to comment Share on other sites More sharing options...
hbalagh Posted August 13, 2007 Author Share Posted August 13, 2007 so any further help on this to get it working would be greatly appreciated...so here is the issue now at hand... the votes are now not added into the database... but it will submit the ip into the db, and if the ip is in the db it doesn't automatically send the user to the results when viewing the poll page like i would like... when i say "the votes are now not added into the database..." that is after i have removed my ip from the db... Quote Link to comment Share on other sites More sharing options...
Orio Posted August 13, 2007 Share Posted August 13, 2007 Try it this way: <?php include('database.php'); if(isset($_POST['action'])) { $a = empty($_POST['a']) ? 0 : 1; $b = empty($_POST['b']) ? 0 : 1; $c = empty($_POST['c']) ? 0 : 1; $d = empty($_POST['d']) ? 0 : 1; $e = empty($_POST['e']) ? 0 : 1; $f = empty($_POST['f']) ? 0 : 1; $g = empty($_POST['g']) ? 0 : 1; $h = empty($_POST['h']) ? 0 : 1; $i = empty($_POST['i']) ? 0 : 1; $j = empty($_POST['j']) ? 0 : 1; $k = empty($_POST['k']) ? 0 : 1; $l = empty($_POST['l']) ? 0 : 1; $m = empty($_POST['m']) ? 0 : 1; $n = empty($_POST['n']) ? 0 : 1; $o = empty($_POST['o']) ? 0 : 1; $p = empty($_POST['p']) ? 0 : 1; $q = empty($_POST['q']) ? 0 : 1; $r = empty($_POST['r']) ? 0 : 1; $s = empty($_POST['s']) ? 0 : 1; $t = empty($_POST['t']) ? 0 : 1; $u = empty($_POST['u']) ? 0 : 1; $v = empty($_POST['v']) ? 0 : 1; $w = empty($_POST['w']) ? 0 : 1; $x = empty($_POST['x']) ? 0 : 1; if(!mysql_num_rows(mysql_query("SELECT * FROM ips WHERE ip='".$_SERVER['REMOTE_ADDR']."' LIMIT 1"))) { if ($a + $b + $c + $d + $e + $f + $g + $h + $i + $j + $k + $l + $m + $n + $o + $p + $q + $r + $s + $t + $u + $v + $w + $x > 0) { $query = "UPDATE results2 SET a = a + %x, b = b + %x, c = c + %x, d = d + %x, e = e + %x, f = f + %x, g = g + %x, h = h + %x, i = i + %x, j = j + %x, k = k + %x, l = l + %x, m = m + %x, n = n + %x, o = o + %x, p = p + %x, q = q + %x, r = r + %x, s = s + %x, t = t + %x, u = u + %x, v = v + %x, w = w + %x, x = x + %x WHERE id = %x"; mysql_query(sprintf($query, $a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l, $m, $n, $o, $p, $q, $r, $s, $t, $u, $v, $w, $x, $id)); mysql_query("INSERT INTO ips (ip) VALUES ('".$_SERVER['REMOTE_ADDR']."')"); } } header("Location: results.php"); exit; } ?> <SCRIPT LANGUAGE="javascript"> function KeepCount() { var NewCount = 0 if (document.form1.a.checked) {NewCount = NewCount + 1} if (document.form1.b.checked) {NewCount = NewCount + 1} if (document.form1.c.checked) {NewCount = NewCount + 1} if (document.form1.d.checked) {NewCount = NewCount + 1} if (document.form1.e.checked) {NewCount = NewCount + 1} if (document.form1.f.checked) {NewCount = NewCount + 1} if (document.form1.g.checked) {NewCount = NewCount + 1} if (document.form1.h.checked) {NewCount = NewCount + 1} if (document.form1.i.checked) {NewCount = NewCount + 1} if (document.form1.j.checked) {NewCount = NewCount + 1} if (document.form1.k.checked) {NewCount = NewCount + 1} if (document.form1.l.checked) {NewCount = NewCount + 1} if (document.form1.m.checked) {NewCount = NewCount + 1} if (document.form1.n.checked) {NewCount = NewCount + 1} if (document.form1.o.checked) {NewCount = NewCount + 1} if (document.form1.p.checked) {NewCount = NewCount + 1} if (document.form1.q.checked) {NewCount = NewCount + 1} if (document.form1.r.checked) {NewCount = NewCount + 1} if (document.form1.s.checked) {NewCount = NewCount + 1} if (document.form1.t.checked) {NewCount = NewCount + 1} if (document.form1.u.checked) {NewCount = NewCount + 1} if (document.form1.v.checked) {NewCount = NewCount + 1} if (document.form1.w.checked) {NewCount = NewCount + 1} if (NewCount == 11) { alert('Please select up to 10 only please') document.form1; return false; } } </SCRIPT> <script type="text/javascript" language="JavaScript"> <!-- function checkCheckBoxes(form1) { if ( form1.a.checked == false && form1.b.checked == false && form1.c.checked == false && form1.d.checked == false && form1.e.checked == false && form1.f.checked == false && form1.g.checked == false && form1.h.checked == false && form1.i.checked == false && form1.j.checked == false && form1.k.checked == false && form1.l.checked == false && form1.m.checked == false && form1.n.checked == false && form1.o.checked == false && form1.p.checked == false && form1.q.checked == false && form1.r.checked == false && form1.s.checked == false && form1.t.checked == false && form1.u.checked == false && form1.v.checked == false && form1.w.checked == false) { alert ('You didn\'t choose any of the checkboxes!'); return false; } else { return true; } } //--> </script> <?php //overview $query = "SELECT * FROM polls1 ORDER BY id DESC LIMIT 1"; $rez = mysql_query($query); $row = mysql_fetch_array($rez); $id=$row['id']; print('<table><tr> <td width="380px" align="left" valign="top" bgcolor="#F3F2FD" style="border: 1px solid #000000;"> <h3 style="text-align: center">Museum Park Opinion Poll</h3> <p style="text-align: center">Select up to 10 amenities</p><font size="-2"> <ul style="list-style-type: none; margin:0; padding:0;font-size:12px;"> <form name="form1" id="form1" action="'.$_SERVER['PHP_SELF'].'" method="POST" onsubmit="return checkCheckBoxes(this);"> <li><input type="checkbox" name="a" onClick="return KeepCount()">'.$row['a'].'</li> <li><input type="checkbox" name="b" onClick="return KeepCount()">'.$row['b'].'</li> <li><input type="checkbox" name="c" onClick="return KeepCount()">'.$row['c'].'</li> <li><input type="checkbox" name="d" onClick="return KeepCount()">'.$row['d'].'</li> <li><input type="checkbox" name="e" onClick="return KeepCount()">'.$row['e'].'</li> <li><input type="checkbox" name="f" onClick="return KeepCount()">'.$row['f'].'</li> <li><input type="checkbox" name="g" onClick="return KeepCount()">'.$row['g'].'</li> <li><input type="checkbox" name="h" onClick="return KeepCount()">'.$row['h'].'</li> <li><input type="checkbox" name="i" onClick="return KeepCount()">'.$row['i'].'</li> <li><input type="checkbox" name="j" onClick="return KeepCount()">'.$row['j'].'</li> <li><input type="checkbox" name="k" onClick="return KeepCount()">'.$row['k'].'</li> <li><input type="checkbox" name="l" onClick="return KeepCount()">'.$row['l'].'</li> <li><input type="checkbox" name="m" onClick="return KeepCount()">'.$row['m'].'</li> <li><input type="checkbox" name="n" onClick="return KeepCount()">'.$row['n'].'</li> <li><input type="checkbox" name="o" onClick="return KeepCount()">'.$row['o'].'</li> <li><input type="checkbox" name="p" onClick="return KeepCount()">'.$row['p'].'</li> <li><input type="checkbox" name="q" onClick="return KeepCount()">'.$row['q'].'</li> <li><input type="checkbox" name="r" onClick="return KeepCount()">'.$row['r'].'</li> <li><input type="checkbox" name="s" onClick="return KeepCount()">'.$row['s'].'</li> <li><input type="checkbox" name="t" onClick="return KeepCount()">'.$row['t'].'</li> <li><input type="checkbox" name="u" onClick="return KeepCount()">'.$row['u'].'</li> <li><input type="checkbox" name="v" onClick="return KeepCount()"> Police / First Aid / Hydration Station</li> <li><input type="checkbox" name="w" onClick="return KeepCount()">'.$row['w'].'</li> </ul> <br /><center> <input type="submit" name="action" value="VOTE!"></center> </form> '); ?> Orio. 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.