I am putting an email activation page for my site together and facing problems. It appears that despite receiving all the necessary information to show the page a successful activation message, it randomly shows an error message that nothing in the credentials database matches. Here's the code
// Check your credentials against the database {$ check = $ db- & gt; Prepare (choose "where from user =? And user name =? And email =? And user_ident =? And active = '1' and email_activated = '0' LIMIT 1"); $ Check- & gt; Bound pattern (1, $ id); $ Check- & gt; Beyond Parm (2, $ U); $ Check- & gt; Bind Parm (3, $ E); $ Check- & gt; Bind Parm (4, $ p); $ Check & gt; Executed (); $ Num_rows = $ check-> Punctiquity (); } Hold (Exception $ er) {// Error: User Tabs Send_email (supportup@site.com ',' Check User - Email Activation Failure ',' User Can not Investigate. $ Er) can go; Go out; } // evaluate for a match in the system (0 = no match, 1 = match) if ($ num_rows === 0) {Send_email (supportup@site.com), 'Email activation credentials no match', ' Invalid email activation variable & Lt; Br / & gt; E-mail: '. $ E. ' & Lt; Br / & gt; User ID: $ id & Lt; Br / & gt; User name: '. $ U '& lt; Br / & gt; User_ident: '. $ P); Header ("Location: message.php? Msg = Your credentials do not match anything in our system"); Go out(); } // match found, you can activate them {$ checking = $ db- & gt; Check ("update users email_activated = 1 WHERE id =? LIMIT 1"); $ Check- & gt; Binduparm (1, $ id); $ Checking-> Executed (); } Hold (Exception $ er) {// Error: User Tabs Send_email (supportup@site.com ',' Email Error Error ',' Active State Can not Set. 'In $ er) was not included in email can go; Go out; }
Sometimes, when clicking on the activation link in the email it will work fine, then again it will throw error by saying that nothing in the credentials database matches HOWVER when I check the database immediately after clicking on the link, email_activated field has been shown that it has been activated. It should not happen technically, if I am doing it correctly, the page goes out after throwing the credentials error, which means that the email_activated update code should never be run. It seems that it can run twice but I have used a counter and it is showing only one run, any help will be very good!
It is possible that the browser is caching redirects. Clearly specify that this is a "302 found" redirect.
header (found 'http / 1.1 302'); Header ('location: / your location');
Or include all of the suggested caching headers as you like:
Header ('End: Sun, 01 January 2014 00:00 GMT') ; Header ('Cash-Control: No-Store, No-Cash, Est-Reckoned'); Header ('cache-control: post-check = 0, pre-check = 0', wrong); Header ('Predama: No-cache');
No comments:
Post a Comment