How to make a user able to connect only once? and how do I restrict a user authorized to vote only 15 candidates and the brand of vote count?

Hello

I'm just doing my project which is the voting system. So my first question is how to make a user or a voter can connect once only using their username and password? After that they brought their vote, they can not be able to connect to a vote. Here, the user name, I replace it with IC and the password I can replace the ID (student ID). Here is my code for the connection:

<?php
if(isset($_POST["submit"])){
$user=$_POST['IC'];
$pass=$_POST['ID'];


$con=mysql_connect('localhost','root','pass') or die(mysql_error());
mysql_select_db('ses') or die("Cannot select DataBase");


$query=mysql_query("SELECT * FROM voters WHERE IC='".$user."' AND ID='".$pass."'" );
$numrows=mysql_num_rows($query);
if($numrows!=0)
{
while($row=mysql_fetch_assoc($query))
{
$dbusername=$row['IC'];
$dbpassword=$row['ID'];


}


if($user == $dbusername && $pass == $dbpassword )
{
session_start();
$_SESSION['sess_user']=$user;
$_SESSION['sess_pass']=$pass;




/*Redirect browser*/
header("Location: main.php");
}
}else{
echo "Invalid IC Number and ID Number!";
}
}
?>

for the second question is how to limit a voter to vote only 15 candidates and counting of the vote that voters go? When the vote is made with 15, then the popup script appears informed that the elector make themselves with their vote.for this I use box as a method of voting and each checkbox have the id which is the primary key. I appoint the id as 'No' and set it as the primary key. Here is the code for voting:

<?php
$servername = "localhost";
$username = "root";
$password = "pass";
$dbname = "ses";


// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
     die("Connection failed: " . $conn->connect_error);
}
    
$sql = "SELECT No, Calon, ID, Jurusan, Image FROM candidates";
$result = $conn->query($sql);

if(isset($_POST['vote'])) {
    
//get the ID value from the radio button form field and store in an array.
$update_vote = $_POST['candidate_id'];

//loop through the array and update the database
foreach ($update_vote as $value) {
$vote_sachin = "UPDATE candidates SET Undi=Undi+1 WHERE No=".$value."";
$run_sachin = mysqli_query($conn, $vote_sachin);


    }

  header("Location:http://localhost/VotingSystem/");
}


?>


<form method="post" id="form1" action="main.php">
<?php
if ($result->num_rows > 0) {
echo "<table border >


<tr>
<th>NO</th>
<th>Candidate</th>
<th>INFO</th>
<th>Vote</th>
</tr>";
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr>
<td align='center'>" . $row["No"]. "</td>
<td><img src=" . $row['Image'] . " width=120px height=150px></td>
<td><br/>" . $row["Calon"]. " <br/>" . $row["ID"]. " <br/>" . $row["Jurusan"]. "<br/></td>
<td align='center'><input type='checkbox' name='candidate_id[]' value='".$row['No']."'></td>
</tr>";
}
    echo "<tr><td></td><td></td><td></td>
    <td><input type='submit' name='vote' value='VOTE'</td>
    </tr>";
echo "</table>";


} else {
echo "0 results";
}
$conn->close();


?>

I hope someone can help me with this because I'm still trying to learn this by my own php code...

Thank you

# 1, add a Boolean column in the table (VoteSubmitted) and the value initially FALSE to follow if the user has already voted.  Check this field when they connect. If the field is set to TRUE, displays a message and cannot vote again. When they get it vote, update the field from FALSE to TRUE.

# 2, I would like to do this with javascript to allow them to select all their candidates and submit once. You could start with something like this:

Cut paste & limit the number of boxes checked script

Tags: Dreamweaver

Similar Questions

  • How many licenses are delivered with the suite? We must be able to connect at work and at home.

    How many licenses are delivered with the suite? We must be able to connect at work and at home.

    A single user license allows you to have two active facilities, in order to have a home and place of work or on a laptop or any other functional scenario where you have two computers with the software installed and activated is allowed.

  • Problems of Battlefield 3 game when connecting to a server: "cannot initialize the display adapter, please make sure that your video card is compatible and the driver so that it is installed.

    Im trying to connect to a server on Battlefield 3 as im log on a server I get a message saying: could not initialize the display adapter, please make sure that your video card is compatible and the driver so that it is installed. Usually, it is a result of the lack of specific driver of the seller then, how can I fix this problem so that I can play Battlefield 3 new...

    Hi Anthany,

    If you have a hardware device that does not properly with your computer, you probably need a driver updated. There are three ways to update a driver:

    • Use Windows Update. You will have to perhaps set Windows Update automatically download and install recommended updates.

    • Install the software from the manufacturer of the device. For example, if your device is equipped with a disk, this disk can contain software that installs a driver for the device.

    • Download and update the driver yourself. Use this method to install a driver that you download from the manufacturer's website. If Windows Update can't find a driver for your device and the device didn't come with software that installs a driver.

    Step 1: Download and install the latest version of DirectX.

    http://support.Microsoft.com/kb/179113

    Step 2: Download and install the latest graphics driver and see if it works.

    Update a hardware driver that is not working properly(Windows 7)

    Good day!

    Answer please if you face concerns.

  • Loss of internet connection after sleep and the computer will not be closed.

    I have a laptop GateWay w / Vista 32 bit OS.  Recently connected to the new internet connection and can connect without a problem.  However, after waking from sleep, the connection is lost, the icon indicates still active connection, can no longer open connection or the computer will restart.  It just hangs and I have to make a hard stop and start again.  If I remive the connection Wireless via safe mode things is back to normal.  However, the cycle repeats when the connection is restored and the computer enters mode "Eve".

    Hi bobert1953,

    This problem can occur when the power management profile turns off your network adapter.

    Method 1: To disable power management feature ent of network cards

    a. click on start

    b. right click on computer

    c. click on manage the

    d. click on Device Manager in the left pane of the window

    e. expand your network card.

    f. now you will see your network adapter or adapters if you have more than one. Right-click on the network component, and then click Properties.

    g. go to the power management tab.

    h. ensure that all check boxes are unchecked (check boxallow the computer to turn off this device to save power is off).

    i. When you have disabled the boxes, click ok and restart your system. Put the computer in mode 'sleep' and check if you still have any questions.

    Method 2: You're also talking about the steps mentioned in the article below, which deals with a similar question

    After you wake up, a Windows Vista-based computer or a Windows 7 sleep mode or Hibernate computer, the network icon and the speaker in the notification area icon do not show the correct state

    http://support.Microsoft.com/kb/937477

    Thank you, and in what concerns:

    Ajay K

    Microsoft Answers Support Engineer
    ---------------------------------------------------------------------------------------------------------
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • Adapter wireless Broadcom - able to connect only to google

    Hello

    I am facing a problem with my wireless connection. I am connected to my wireless network, but not able to surf the net. I am not able to go to any Web site other than Google.com or google related websites (like gmail, orkut). Don't open all the other sites (cnn, yahoo, etc). This is a brand new laptop and I also did a system recovery. I also tried to download updated driver available for card "Broadcom 802.11a/b/g wlan.

    Please could you provide a pointer as to what could be the problem?

    the problem is resolved. I read on some forum that Broadcom wireless adapters do not work with WPA wireless networks. So I just change the type of my network wireless for WPE. This has solved the problem and I am able to connect to all websites using my wireless connection.

  • Connection to host and the State of food in ESXi 5.0

    Hello everyone,

    I have a clsuter running in a center of V after that I have created anothere DR cluster in Vcenter even with three guests: VMware ESX 5.0 (three host)

    My problem is: after I add the hosts alarmed "connection server alarm and power status" every 5 Min in newly instlled three welcome only after three host are disconnected to

    I check DNS, IP/mask, gateway, cable, etc... nothing, Iam also capable of these server ping and able to NSlookup, but this error is not gowing. also confuigure HA cluster Again * three times)

    Thank you

    TechExpert

    Do you have firewall between vcenter and DR ESXi may to check you if the required firewall port is open between ESXi and VC/DNS servers, in order to avoid the frequent disconnection of esxi to VC.

    port to open between vc and esxi

    902, 5989, 80,443,623, 8000, 8001, 6500, 514,8080

    port to open between esxi and dns server

    53, 88, 389

    See below for more information:

    http://KB.VMware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalID=1012382

  • Slow connection after reboot and the lock

    I have Windows 7 (64 bit) operating system and the model is Dell OptiPlex 390. The system works well in many ways. However, every time I lock the screen or you restart the computer, it takes about 8-10 minutes to enter the system. The screen is hit with only welcome. I tried the boot environment, but I am always faced with the same question. The machine is in the field and I have also reinstalled the network drivers. I tried all the steps from the web, but it still doesn't work. I hope that I have the solution to this forum, unlike in my previous questions, where no one answered. I am willing to provide any other information.

    Hi Rajiv,

    The computer is connected to a domain network, your question of Windows is more complex than what is generally answered in the Microsoft Answers forums. Appropriate in the TechNet forums.

    Please post your question in the Windows 7 IT Pro TechNet Forums: http://social.technet.microsoft.com/Forums/windows/en-US/home?category=w7itpro

    Thank you.

  • I have problems to connect to ePrintCenter and the password recovery link does not work for me.

    I have a PhotoSmart 5510e which was working fine until recently these app printing stop work and display of messages that I need to go to for custom ePrinterCenter it. Has tried to open a session in the ePrintCenter but it keep telling me the password is not valid. And when you use the password to get the link, it keeps telling me to enter the email address associated to the my account when I click OK. I already have then enter the email address what do I do? Really need to connect if I use the App founction on my printer. My computer is running Win7 64-bit.

    Hello jc111,

    I would like to apologize for the problem you are experiencing.  The eprintcenter.com site and the site snapfish.com are connected.  It is possible that you had a printer in the past that you signed up for an account with snapfish, while you were recording with us and you didn't.  I would try going to snapfish.com and using the forgotten password under their log link to see if who you alow reset you the password.  Once the password is reset, log information Web site snapfish.com will be information to use to connect to eprintcenter.com.  If you need anything else please do not hesitate to answer.

  • How to make a 'page' adjusted zoom my image size and the default text?

    I use a Netbook, which has a small screen, so I generally "zoom" to enlarge the appearance of text and images. Is it possible to block a desired zoom level so that I don't have to adjust each new tab or window I have open?

    You could try the add-on squint No....
    http://bit.LY/bC6b9V

  • our airport time capsule connects to computers and the internet, but does not record on the usefulness of the airport as being there - is it dying or is their a reset?

    Our computers connect via wifi to a capsule of time to the airport and to the internet, but can't find the time capsule, nor can its hard drive. Y at - it a reset, we can try or he dies. It's only a couple of months.

    Turn about your Airport Extreme for 15 seconds and then power back on. As soon as you see the green light, you should be able to see him for a minute or two in the Airport utility. In the affirmative, and see if you have Back to My Mac active. If so, disable it by removing all the e-mail addresses of the back section of my Mac. Then update your Airport Extreme. Work quickly.

    Many have started having this problem within the last week, probably because Apple changed something in its servers CCMM. A real difficulty would come from Apple, but it should work if you currently have active CCMM.

  • I lost the ability to upload files to a Web site. I transfer files from my computer to a web site and I get an error message "the connection was reset" and the file will not download. I try to transfer the photos and I get the same message.

    I have download a scanned receipt on a Web site and I get the error message "the connection was reset". I downloaded these reception for two years and last week, I had to use a different browser to complete this operation. I log onto the site and make the report, I have to do, but I can no longer download on this site.

    Safe mode does not work. However, when I downloaded Firefox laptop everything worked. Any suggestions as to where I should go now. Thanks Fire Fox works on other sites I work with. The download has started working. I think the problem was the website.

  • How much to fix a MacBook pro Retina display? I dropped it once and the curved screen

    Hi a few months back I dropped my MacBook Pro 13 inch retina. The screen is folded and no indication on the screen. I have been using a hdmi to tv connection, but I want my old screen back. only I was wondering how Apple will charge for repair or is it preferable to simply consider other repair workshops too get offers.

    Thank you

    https://www.TechRestore.com/Mac/

    http://www.dttservice.com

    http://www.myService.com/MacBookPro.html

    https://www.iFixit.com

    http://www.PowerbookMedic.com

  • using you connect in front and the order of

    Hi friends
    I have a simple table, which is like the tree and its columns id, parentid and its name

    I create the shape of the tree the data in the table simply to connect before. but I want to do the sorting with order of according to name

    for example
    Table
    id     pid     name
    1       -         abc
    2       1         bbb
    3       1          ab
    ......
    my query result must be
    ABC
    AB
    BBB

    How can we use sort
    Thank you

    need to order the brothers and sisters in desc... ??

    an example

    SELECT last_name, employee_id, manager_id, LEVEL
    FROM employees
    START WITH employee_id = 100
    CONNECT BY PRIOR employee_id = manager_id
    ORDER SIBLINGS BY last_name; 
    

    Ravi Kumar

    Published by: ravikumar.sv on October 22, 2009 12:40

  • I press connect on WiFi and the computer tries to connect to literally one second then stops?

    Need help! But I can connect to my home WiFi, because it was on "connect automatically" before the problem started.

    Hello

    1. have there been recent changes to the computer before the show?

    2. do you get an error message?

    I suggest to follow the steps provided and we update on the State of the question.

    Method 1:
    Try to run the network troubleshooters.
    http://Windows.Microsoft.com/en-us/Windows7/open-networking-troubleshooters

    Method 2: If the problem persists, then try the steps from the link below.

    In the Windows wireless network connection problems:
    http://Windows.Microsoft.com/en-us/Windows/help/wired-and-wireless-network-connection-problems-in-Windows

    Check this link for more information:

    Why can't I connect to the Internet?
    http://Windows.Microsoft.com/en-us/Windows7/why-can-t-I-connect-to-the-Internet

    For all windows questions do not hesitate to contact us and we will be happy to help you

  • Affecting the number of HTTP 1.0 connections simultaneious 8 and the number of HTTP 1.1 to 4 connections siumultaneious

    Recommendation of AVG PC Tuneup

    Its okay to do it but I would not recommend to any type of 'tune up' even a company as trustworthy as AVG as etc. most registry cleaners have usually little or no effect.

Maybe you are looking for

  • My phone shuts off and is always in charge of the battery

    On the forfeiture of this last month, I realized that I have a problem with my phone's battery. My Iphone 6 loads normally and I can use it without any apparent problems, but several times it shuts down itself without any reason at all, just as the b

  • Is it possible to prevent automatic scrolling in the history sidebar

    Something that has always been an annoyance for me and perhaps the solution is right under my nose.When I watch something in my story, but I'm not sure of the exact link, I often have to toast on several pages to find the exact. The problem is every

  • Qosmio F50 - locking touchpad does not work

    Hello FN + F9 does not seem to work (touchpad is still active). I have the drivers for alps touchpad.All other FN keys working. I saw the other responses on this topic and all seem to have associated with model solutions.

  • Pavilion h8 1212c compatible graphics cards?

    What new video cards are compatible with the motherboard at the Pavilion H8 1212c with latest version of the BIOS (and update power)? I'm looking for a better gaming experience, IE: Nvidia GTX 750 or similar. Current card is a geForce GT 520, who sim

  • HP Pavilion 15 laptop: The PC fan runs continuously

    After 5 min, I turn on my PC the fan starts working and it will not stop until I have turn off the pc or put it into sleep mode. I open the back cover and tried to clean the fan, but nothing has changed. my current CPU is only 12% and the memory is 7