Tagged Questions
PHP is a widely-used, general-purpose scripting language that is especially suited for web development.
0
votes
0answers
13 views
simple fetching data and conversion into json using two different pattern
I'm trying to fetching the data and convert into json format. Some days ago I was using the mysqli but someone told me this is susceptible to SQL injections when i asked a question for code review. ...
1
vote
2answers
64 views
A find method on a Product class
The following class holds an array with products that are generated from a Json file. This is what the json file looks like
...
-1
votes
0answers
11 views
Admin panel, secure login
I ask information to you that you are much more experienced than me that I am learning. I would like to create an administrative panel with the only possibility to be logged in to the admin. Your ...
1
vote
0answers
139 views
Using a singleton for a collection of discounts to calculate?
I'm wondering if using a Singleton for a storage of discounts is the right way to go. This is because I will be looping over all added discounts in another class.
client code
...
1
vote
0answers
31 views
PHP Lottery Simulator
I have a lottery simulator on my website that simulates you playing the lottery every week until your death and tells you how much you would have won or lost. It can take a custom number of balls and ...
3
votes
0answers
35 views
Fantasy league tracker for Game of Thrones
So I've just started learning about MySQL and PHP to create a fantasy league tracker for Game of Thrones for my office. I got it to technically work fine, but I think it's way clunkier than it has to ...
0
votes
1answer
33 views
Repeating HTML, minus a few class and array key differences
I feel like this code is pretty sloppy and can be accomplished in a foreach loop. But it's a bit complex using a multi-dimensional array.
Can this be cleaner? You ...
1
vote
1answer
47 views
Self or this in a Class? [on hold]
I have written a class that stores users activity.
To store user activity, ActivityModel::record('edit', get_class(), $database->lastInsertId()); is called from ...
0
votes
0answers
23 views
Creating Mysql interaction/connection using OOP in PHP [closed]
I'm very new to OOP and but am aware of the concepts after educating myself with some good resources despite this I want to get expert knowledge on the direction I'm taking for this project I've set ...
2
votes
1answer
79 views
+100
Session expiration handler using PHP and jQuery
At this point i am interested to see other techniques on handling session timeouts.
What are some good improvements on this script to detect when a session is no longer valid?
Important definitions:
...
2
votes
2answers
40 views
User registration with Repository pattern
I have been developing a simple login registration page with PHP using the repository pattern. Following are the business rules :
During registration
Email must be unique.
Email must be a valid ...
5
votes
2answers
71 views
Adding an item to database + JSON
Is this code good? Or is it the noobiest PHP you've ever seen?
...
2
votes
0answers
25 views
PHP routing system
I made a routing system for PHP inspired by Symfony's router composed of a few classes.
First I am using Symfony's HTTP Foundations component.
Then, I am emulating the classes in the routing ...
-4
votes
1answer
35 views
3
votes
2answers
35 views
A PHP MVC controller to display a form and add an item to the database
I am creating a controller that will display a form and once the form has been submitted to store the item in the database. After the item has been stored the user will be redirected back to the main ...
1
vote
1answer
27 views
Simple bcrypt Register User and User Login using PHP - is this approach acceptable?
I am learning PHP and have been looking into a suitable way to safely store password data in MySQL.
Following advice from here ...
-3
votes
0answers
23 views
What Changes Should i make to my PHP code to get the desired output? [closed]
I want to create a adaptive test which selects a specific subject id and increases or decreases the difficulty according to response.
The code below doesn't work properly - this is the last ...
1
vote
0answers
19 views
7
votes
1answer
79 views
Repository Pattern without an ORM
I'm trying to learn the Repository pattern, and I have some questions regarding my current understanding of it.
All the examples I've been able to find of database repositories use ORMs, but for a ...
4
votes
2answers
57 views
Using PHP PDO to Fetch Employee Details
Introduction
Hi, I am finally making the move to object oriented PHP.
This has been something I have been quite reluctant to do, but I now feel that it could benefit me, and bring me up-to-date with ...
1
vote
0answers
37 views
Efficient MySQL PDO Class
I tried to create a secure and efficient PDO class.I would really appreciate your feedback to make it more production ready.Github Link
...
15
votes
4answers
2k views
PHP gaming community website
I created a gaming community website about 13 years ago. It uses PHP, SQL, HTML, and CSS, and does not use a framework or template engine. It includes features such as a login system for members, ...
3
votes
0answers
42 views
Checkout process
I'm building a checkout process where I am quite frequently making SQL connections based on user input so this is quite important. I want to know if it's well-protected from any SQL injection or other ...
0
votes
2answers
64 views
3
votes
1answer
47 views
Uploading multiple files using a class
Below I have implemented a class that will validate and upload files based on the specified rules.
...
3
votes
1answer
60 views
Is this query vulnerable? ( MySQL Injections )
Already many days I'm documenting about the SQL Injection. I was wondering if the code I wrote is vulnerable in some of its parts.
...
-1
votes
0answers
31 views
Dynamic boostrap dashboard
I am creating dynamic dashboard, where each column of row will be considered a screen. The system picks various screens as an array that is formatted as follows:
...
1
vote
0answers
40 views
Handling errors in a PHP class to submit two forms [closed]
I am trying to handle errors in a class written in PHP and using curl. This class uses 3 functions (init, ...
4
votes
1answer
61 views
PHP secure login script
I was just wondering how secure my code looked and if I'm overlooking any serious mistakes. Any suggestions/critiques are welcome.
This is my relevant login script.
login.php
...
0
votes
1answer
51 views
Shuffle array without duplicates
I made a function about random backgrounds
And those images will unique as possible. (Shuffle again after all gone)
My steps is :
Setup the array
Shuffle it
Do function (check if ...
3
votes
1answer
41 views
Template for PHP service (/etc/init.d) script
I wanted a template for a service script that is versatile and easily configurable.
Along with producing similar outputs to the SSH and Samba daemons, I request the code to be as clean, simple and ...
4
votes
1answer
551 views
Get image from other site in PHP
I would like to get images from other websites.
This is my current method but I'm not sure if it is alright.
...
1
vote
2answers
51 views
Logging out users securely
Is there anything I need to add or is this the best security possible?
...
2
votes
2answers
73 views
0
votes
2answers
48 views
-2
votes
3answers
137 views
Executing a query with or without bound variables
I know there's a more compact way of doing the following code but I haven't been coding PHP in a while and I completely forgot how. Pretty sure its to do with : and ...
2
votes
1answer
74 views
Using PHP's password_hash and password_verify for a login function
This is my first time using password_hash and password_verify in PHP. Would this be the correct usage of ...
0
votes
1answer
48 views
Inserting a role using PDO
My question has to do with :
(a) Can this be made more secure?
(b) Are there best practices in relation to setting timezone?
(c) What best approach should be taken defining use of utf8?
...
2
votes
2answers
84 views
3
votes
1answer
76 views
Accessing Data inside Presentation Layer from API: Laravel 5.2.27
I wrote the code to fetch the JSON Data. For that I tried to do this in 2 projects.
First Laravel project which has API code for database interaction only.
Sample code in API controller
...
0
votes
0answers
37 views
User management library after hard reject on Codecanyon
I spent 2 months working on a user management library, with the intention of selling it on Codecanyon (I've never sold anything there before).
On Codecanyon, there's a screening process for ...
1
vote
2answers
32 views
Displaying a greeting to one user selected from a database
I execute the following SQL statement to get back an data object into a variable.
...
0
votes
1answer
51 views
Slim 3 dynamic middleware code optimisation
Recently I started playing a bit with Slim and what is making me confused is a necessity of container and middlewares hard coding. As because I am a staunch supporter of a dynamic loading I decided ...
1
vote
2answers
83 views
2
votes
0answers
33 views
Function to prevent sign-in form from being spammed
I have written a function that I want to protect from spam bots. I have used two techniques the first being filter after submit. After reading around I obtained the ...
5
votes
2answers
263 views
As basic as routing in PHP can get
I'd like to have neater URLs, no more and no less — I'd like to be able to write /page/subpage instead of something like ...
3
votes
1answer
59 views
Generate 6 random numbers for lottery in PHP
This program generates 6 random numbers between 0 and 45 and the numbers cannot be reapeated. Can this code be improved?
...
2
votes
1answer
45 views
Script that retrieves trending topics from Twitter
The following code fetches trending topics from Twitter's API using a WOEID. It caches the response, loading from this cache the next time if its relatively fresh (generated within the last 15 ...
1
vote
2answers
63 views
Two classes to validate and store an e-mail address
I'm trying to improve my limited knowledge in PHP (7) and I wrote these two simple classes as a proof of concept.
They both have just one (private) property ->email and they run validation before ...
2
votes
1answer
129 views
Profile picture upload method in Laravel 5.2
I am a Laravel newbie so please forgive me for my code... I have a method, in a Laravel controller, that updates the current logged user profile (...