Problems related to a simple voting system example made by php

Source: Internet
Author: User
In a simple voting system example made by php, the number of votes does not change after the web page is voted, but the number of votes in the database is changed. the code for changing the number of votes on the web page is as follows: PHPcode & lt ;? If ($ voted & amp; $ already_voted) {$ SetCookie (& quot; already_vot a php example of a simple voting system
No votes remain unchanged after the web page vote, but the number of votes changed in the database will change accordingly.

The code is as follows:
PHP code
  
      Online voting system    Online voting system

Theme: our elected squad leaders

The database only has one table vote_banzhang (votee varchar (12), vote_numbers int (4) master code)

------ Solution --------------------
Debugging is enough.
Output the POST value;
Check whether the mysql connection is successful;
Check whether the query execution is valid;
------ Solution --------------------
You didn't say that you had any trouble.
Add an error_reporting (E_ALL | E_NOTICE); to the top of the code );. Open the error prompt and check what errors are reported.

In addition, let's take a rough look at $ SetCookie ("already_voted", "1"); what is this?

------ Solution --------------------
The data is not stored in the database. it should have not received the value. you should make an IF judgment to determine whether the value has been received before the village database

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.