Iustin Beceneagă Iustin Beceneagă - 1 year ago 80
MySQL Question

Store a PIN of user in an array of PINS in mysql with php

I need some help with my project.
I have a voting form, where any wordpress registered users can vote once then their PIN (an unique number are stored in an array of PINS) so the button "vote" will be disabled.
I don't know how to store the pin in an array, and then putting conditions

while($row = mysqli_fetch_array($q)) {
$id = $row[0];
$title = $row[1];
$pollid = $row[2];
$pin = $row[4]

$pin = $current_user->user_pin; (stores the wordpress current user's PIN)

Answer Source

I don't get you actually,As I hope I am understand correctly.

Case 1: as you suggested

 $pin = $current_user->user_pin;

You can push an element after vote to dummy array.


Case 2: Instead of array please use a flag in database

I think vote is very sensitive data.

  • So that you add one more column in wp_user table lets consider as voter_flag
  • set default value 0
  • Update flag after vote
  • while render page again check if user is voter_flag is 0 then active button.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download