Php Error - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Php Error (336 Views)
| Php Error by dodoisk(op): 9:10am On Mar 14, 2021 |
guy am having issues in php. Am building a result checking website. How do i make the expiring date to be once even after the user login so many times
|
| Re: Php Error by salvationproject(m): 9:48am On Mar 14, 2021 |
Simple... Wen u accept a PIN as valid, check if it has been used before. if yes, no need to create another record on db with expiry date but if the PIN has not been used before, then, create a record with expiry date... I hope u get... |
| Re: Php Error by Karleb(m): 10:22am On Mar 14, 2021*. Modified: 1:07pm On Mar 14, 2021 |
I believe the issue you are having is that you have different tables for student and pin, which is actually a very good design. What you need is to join the students table to the pins table and check if a student has an existing record in the pins table, if it exists you do nothing or you update, if it doesn't you create a new record. This would bring us primary and foreign keys. Your students table should have a primary key which should auto increment, now this primary key would be stored in the pins table. That means, whenever you create a student record a new pin record is created for the new student automatically. I hope it solves your problem. Let me do a little code review here. ![]() You don't need to declare a variable before you use it in latest versions of PHP. A variable is enough for all the alert messages. I also believe switch statement will do better than that long if else elseif logic. As for the date logic, you can use date('Y-m-d') without assigning to a variable. The $expire_date variable could be written properly as: $expire_date = date('Y-m-d', strtotime('next year')); |
| Re: Php Error by Nobody: 9:40am On Mar 16, 2021 |
Why not build your result checker app in OOP? PHP is moving from procedural programming and you will find it really stressful when you have to add more features to your app later on. ———————————————————— I just checked. Looks like a mix of OOP and Procedural. |
I'm Getting An Error While I Run This Python Codes • Who Can Decipher This Error For Me? • I Keep Getting This Error Message "Gradle Project Syn Failed... • 2 • 3 • 4
Do You Use Steroids, If So What Kind? • Eastwest Properties - Property For Sale • I Need A Legit Adsense Seller Asap
