I have an application where members are voting in an election of officers and I need to limit them to only being able to vote once. My members are in a table called registers with the key being set to r_id , it contains their username (uname) and password (passwd). The voting table contains the key (id) vote (vote) and relationship key (r_id). I set the master-detail relationship to registers (r_id) with the r_id in the vote table. I set a hard path to the add.php. My objective was to change the password to an arbitrary value when the person voted and them redirect them to a landing page.
In the add page I entered the following event code in the before record added event:
global $conn;
$strUpdate = "update registers set passwd=98765 where r_id=r_id";
db_exec($strUpdate,$conn);
and in the after record added did the redirection to the landing page.(Worked fine)
- When the first person voted it of course updated(which means it ignored my "where") all 3908 rows of the table instead of the one voting. I assumed that the conditional left side of the argument got the table from the "update registers" and the right side was always the working table.
- Exiting the application apparently leaves a login cookie set, which if the person voting reclicked the link could immediately vote again with no login required.
Incidentally, I have five versions of this all stand alone in parallel directories for voting different work groups.
Suggestions on a fix.
Jim Freeman