This topic is locked

Updating field in another table 4.2 Posted in wrong forum this am

10/13/2008 4:32:50 PM
PHPRunner General questions
jimhnet author

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)

  1. 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.
  2. 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

J
Jane 10/14/2008

Jim,
answered in your personal email.