please, need help coding this voting for your favorite car polling system.


Posted on 16th Feb 2014 07:03 pm by admin

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>&nbsp;</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">&nbsp;</td>
<td width="608"><div align="center">VIEW THE UPDATED TOP TEN CARS</div></td>
</tr>

<tr>
<td>&nbsp;</td>
<td><input type="submit" name="submit" id="submit" value="submit" /></td>
</tr>
</table>
</form>

</body>
</html>

No comments posted yet

Your Answer:

Login to answer
309 Like 37 Dislike
Previous forums Next forums
Other forums

change text color with a jQuery code
Hihow can I change the text in a asp:TextBox to a different color when I start typing using jQuery?I

mysql select query problem
how can i select multiple fields from multiple table in one query like

i have table name t1 a

Need help making a blockquote and line items conditional
I have some code I bought a few years ago that allows my clients to update content on their site usi

Javascript or not?
How many people prefer javascript/ajax sites? How many prefer the good old fashion straight php sit

How to get exact 3 moths post date from today date using javascript
How to get exact 3 moths post date from today date using javascript
Please help

upgrade from 4.7 to ECC 6.0
Hi all,
we are going to do an upgrade from R/3 4.7 to ECC 6.0. I need to know if i can find som

update 2 columns by doing inner 2-column query
Hi,
is something like this possible?

update contract_all set col1,col2 =
(

max() problem
I have a while loop to get image names.
Code: $imagequery = mysql_query("SELECT * FROM ad_i

Inserting the current date/time while submitting the forum
What do I need to add below to update the current date/time? I have a field in the database called d

Help uploading .JPG
I have a problem with upload images when the ending is .JPG capitalized.. I really don't know what c

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash