Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,157,932 members, 7,835,112 topics. Date: Tuesday, 21 May 2024 at 04:46 AM

Php Error - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Php Error (263 Views)

Website Showing Error 403 After Unzipping File To File Manager / An Error Occurred At Log Record Id. / Sql Error Msg 1801, Level 16 During Execution In Ssms (2) (3) (4)

(1) (Reply) (Go Down)

Php Error by dodoisk(m): 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...

1 Like

Re: Php Error by Karleb(m): 10:22am 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. grin


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'));

1 Like

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.

(1) (Reply)

Technical Certifications Online / Get Your Pure And Potent Omega 3 Salmon Oil - Natural Health Products. / How To Make Automatic Writing Machine

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 10
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.