hi, my code needs a lot of work, but i want to be able to let users vote on their favorite car, update the database, and display the new updated data for the top ten cars listed. i want to prevent multiple votes by ip but i dont know how, but any help with the voting part of the code GREATLY appreciated, as my google tutorials seem to only show premade code.
here is the page so far.
Code: <?php
include("connect1.php");
ini_set('display_errors', 1);
error_reporting(E_ALL); // GREAT SNIPPET FOR DEBUGGING OUTPUTS ERRORS TO SCREEN */
////////////////////////////////////////
////////////////////////////////////////
// escape username and password for use in SQL//person said on board "looks fine" like this
//to prevent sql injections
$make= $_POST['make'];
$model = $_POST['model'];
$year = $_POST['year'];
$color = $_POST['color'];
$make = mysql_real_escape_string($make);
$model = mysql_real_escape_string($model);
$year = mysql_real_escape_string($year);
$color = mysql_real_escape_string($color);
$find = $_POST['find'];
if(isset($_POST['Submit'])){
$vote=0;
$vote++;
echo (" You have voted for a ".$color. " ".$make." ".$model. " ...year: ".$year.".");
mysql_query("INSERT INTO cars (make, model, year ,color , vote ) VALUES('$make','$model', '$year' , '$color',' $vote'"); //ON DUPLICATE KEY UPDATE courtesy = courtesy + $courtesy, stability = stability + $stability, loyalty = loyalty + $loyalty, attitude = attitude + $attitude, votes = votes + $votes");
}//end isset
//output the cars row into an array and the list the top ten
if(isset($_POST['submit'])){
$query="SELECT make, model, year, color, vote
FROM cars
WHERE votes (is the most number of votes) ;
$result=mysql_query($query);
if(mysql_num_rows($result) > 0)
{
$topcars = mysql_fetch_array($result); //put cars row into an array $topcars
}
echo( "Top ten cars ". $carone."
".$cartwo."
". $carthree. "
".$carfour."
".
$carfive."
".$carsix. "
". $carseven. "
".$careight."
".$carnine."
".$carten .
");
}//end isset
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Top ten .com </title>
</head>
<body>
</p>
<div align="center">welcome to <strong>vote your cars</strong> </div>
<p>Please enter your vote your favorite car.<span class="style4"></span><br />
</p>
<form id="form1" name="form1" method="post" action="cars.php">
<table border="0">
<tr>
<td>Make</td>
<td>
<input name="make" type="text" id="make" /></td>
</tr>
<tr>
<td>Model</td>
<td>
<input name="model" type="text" id="model" /> </td>
</tr>
<tr>
<td>Year</td>
<td><input name="year" type="text" id="year" /></td>
</tr>
<tr>
<td>Color</td>
<td><input type="color" name="textfield" id="color" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit" /></td>
</tr>
</table>
</form>
<form id="form2" name="form2" method="post" action="cars.php">
<table width="666" border="1">
<tr>
<td width="42"> </td>
<td width="608"><div align="center">VIEW THE UPDATED TOP TEN CARS</div></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" id="submit" value="submit" /></td>
</tr>
</table>
</form>
</body>
</html>
Passing variables with pagination - iterating through unique id per link
Hi everyone,I have seen a few topics like this one. Still cant find the specific thing, so I am asking - does anyone know this?I am trying to combine a mysql query with this code I found at
ScriptManager History and Opera Issue
I am having an issue in opera with the ScriptManager. I have a ScriptManager on a page with history enabled. On the same page i have 5 LinkButtons which update Panel content. On the OnClick event of
SESSION CHECK WORKS "MOST" of the time... whats going on?
i have a sign in check thats included in every page that is a members only page which is basically all of my pages. that im working on anyways..but heres the code..... that works MOST of the time.
Typedef struct vs just struct
Anyone know the rationale for using typedef for structs when a struct is itself a typedef? I have seen this in just about every book I have ever read, never with any explanation, yet I know from
How to search for several parameters from objects in a database?
I have a database with lots of information about objects.Now I would like to search for 4 or 5 parameters at the same time (from a form) like this:I choose from a select-box one parameter and then
Pagination won't carry results past page 2.
Hi all,I've worked out my pagination script and its paginating fine until I click next from page 2 at which point it stops displaying results. I know its something really simple, but can't see what
Question handling xml data
Hello, I have sucessfull followed this tutorialhttp://www.phpfreaks.com/tutorial/handling-xml-dataand used xpath to find the books I need, here is my codeCode: [Select]<?php// load
New to Arrays
Hi I am new to PHP (a week and a half now) and I am just beginning to read about arrays. I understand simple arrays, associative arrays, and multidimensional arrays also. The book I am reading
writing my own sobel filter convolution - something is wrong
I am trying to keep it very simple, I cant see anything wrong with my logic, could anybody help point me to the right direction?!! Code: { int Shorizontal[] = {-1, 0, 1, -2, 0, 2, -1, 0, 1}; int
Async WSAConnect failed on XP with error code = 2 ("File not found")
Hi all,