Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [php]

PHP is a widely-used, general-purpose scripting language that is especially suited for web development.

0
votes
0answers
14 views

PHP User management class

Here is my code for a class that is responsable to manage some common users task like registration, login and logout. It implement also a sub class that can be used to check the session of a logged in ...
0
votes
0answers
10 views

Get existing record or create new one [on hold]

There are two scenarios in the business: New user signs up, contract needs to be created Existing user buys additional product, existing contract needs to be retrieved Now, at the moment both ...
-1
votes
0answers
16 views

AppContext vs AppConfiguration [on hold]

We have a project where we have AppContext and AppConfiguration classes, like ...
0
votes
0answers
8 views

PHP custom contact form on Magento

Below is the working controller class for a custom contact form on Magento 2 that handles form submissions. All of the fields are input arrays like [general-info][city]. Magento uses the Zend ...
2
votes
0answers
73 views

PHP Login Checker Stage

I have been working on my script which allows people to sign-up and login to my website. I was wondering if someone could review the code. It works but I can't help but feel it could be optimized. ...
1
vote
1answer
55 views

Auto generate database table

I have written my own little auto-generated table class, and I was wondering if you guys can give me some tips on how to make this code more elegant and secure and maybe compact it so I use only one ...
-1
votes
0answers
16 views

Integrate API from different vendor [on hold]

Let say I have a function to create some data (for example new customer). When I create a new customer in my system, I need to call API from one vendor side so we can insert this data to their system ...
0
votes
0answers
15 views

Multiple div element and call it on Javascript [on hold]

I suppose that if I check the checkbox, it also appears status false or true on the table. But it only appears on the first row. The second and the third row do not show the status. Why is that? How ...
1
vote
1answer
23 views

Laravel image upload

I'm new to the filesystem from Laravel, but I need an upload script that allows users to upload images to my server. However, i'm concerned about securety, so I thought why not ask for advice, because ...
1
vote
0answers
41 views

PHP OOP front controller pattern

I've started a course about the MVC pattern applied to the web. I want to improve my PHP programming skills so I've decided to write a simple boilerplate for my webapps that use the front controller ...
0
votes
0answers
42 views

Representing data retrieved from an API

I am using using an Entity class to represent data retrieved from an API (using guzzle). There will be many Entity classes such as Note, ...
1
vote
0answers
42 views

Dependency resolver in PHP

I wrote a simple Dependency Resolver in PHP that I'm hoping to get some input on. The main problem that gave me some trouble was when it had to resolve typed arguments ( like type hinting a ...
1
vote
1answer
57 views

Basic PHP user authentication system for an Elm app

I made a simple authentication system with php for an elm webapp that will have a small number (1 - 5) of users able to log in. I am planning to send the users their php session-id at login, and ...
0
votes
1answer
41 views

More readable approach? [closed]

This is a fairly short code snippet, but it made me a little headache, because it is hard to understand, isn't it? ...
2
votes
0answers
43 views

Best approach to parse data from multiple APIs to Entities in PHP

I built an application that extracts and updates data from multiple ecommerces websites. Each eCommerce is either built using platforms/frameworks such as Shopify, Prestashop or WooCommerce. This ...
0
votes
0answers
38 views

PHP Hooks - What is best approach for the global data?

In a config.php file: hook::set('test', function($args) { return 'Hello ' . $args; }); Somewhere ...
2
votes
0answers
51 views

Dependency Inversion in constructor

Currently I'm learning OOP and meanwhile I'm trying to keep the SOLID principles. Is it right to inject dependency (GenName - generate file name) on File ...
1
vote
3answers
106 views

PHP script security for new user registration

I would like to ask the experts here if this is secure. If it is not can I get an explanation as to why it would not be secure? I have been reading off and on on sites for this and I have trouble ...
1
vote
1answer
40 views

Check PHP validation code

I have made a form in HTML and the form data should be send via email. For that purpose I have created a PHP script. I did read a lot about the importance of form validation in order to prevent ...
2
votes
2answers
59 views

Simple implementation of LRU caching in PHP

This is my implementation of LRU caching in PHP. It works fine when I tested as. What are the things that I miss or need attention? ...
1
vote
0answers
20 views

PHP email list schedular with fixed hour limit

I am working on bulk mailer. So I want start sending email on specific time which is choose by user. But there is he has limit. So, for example they have total email 250 and want send 25 email per ...
0
votes
2answers
57 views

Use a comma-separated field in another SQL query

I was just wondering if there was a better way to write this block of code in php. I have a string with values separated by commas. I need to prepare that string to pass it on to the query using IN ...
0
votes
1answer
32 views
1
vote
2answers
78 views
4
votes
2answers
43 views

Solve Project Euler #4 in PHP

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit ...
0
votes
0answers
35 views

Simple Search System using Method “POST”

index.php ...
0
votes
0answers
32 views

Insert into database from three different queries

I have 3 tables: user_group_insurance user_insurance user_policy_group How could I ...
1
vote
2answers
55 views

PHP login/signup validation class

I am working on a blog with PHP, specially in order to practice OOP. Since the blogging system will handle users, i thought that a Validation class would be a good idea in order to not repeat code ...
2
votes
0answers
19 views

How to connect a propery class/object with a collection (its database class)?

I'm struggling with organizing my code regarding 'best practise'. In particular how I link a class with its collection class. I've 2 classes: ...
1
vote
0answers
34 views
1
vote
0answers
18 views

Send single notification script until state change

I could not find the script I was looking for, so I made my own with the knowledge I have at this moment. This is my custom PHP script to send a single notification/SMS/email when a script or site is ...
0
votes
0answers
25 views

Is this a 'proper' use of a trait in PHP? [migrated]

In Laravel 5.6 an Illuminate\Database\Eloquent\Relations\BelongsTo relation was given the ability to support default models. This allows a model that will be ...
1
vote
0answers
49 views

Displaying a user profile based on a mock ORM

Overview We are learning PHP OOP and decided to create a simple app with 3 database tables, one a basic users table, the other two containing information about the users' favorite food and favorite ...
2
votes
0answers
95 views

PHP login script using mysqli

Can you guys tell me if my login is secure? Login.php ...
0
votes
1answer
23 views

Results Reporting / Checking with Multiple Results in For Loop

hoping to be schooled a little bit here in showing "no results". This is a working snippet, but I'd like to know if there is a more elegant way to show errors when comparing multiple values in an IF ...
0
votes
0answers
55 views

Repository that performs API calls internally - DDD [migrated]

Please note: although my question relates to DDD, I am also interested in this from an architectural and OO design perspective. This question may also be a simple case of CQRS and/or interface ...
2
votes
1answer
51 views

Showing all records on a webpage

I have a connection with my database to show all my records on a webpage, and I'm not sure if this code is safe: ...
0
votes
1answer
38 views

Fetch Reattempt and Hold Date count in efficient way

I am using 4 queries to get below 4 values , like this i need to use about 14 queries , Is there any way to reduce queries ? ...
2
votes
1answer
34 views

PHP Factory Pattern : Should I use `create()` or `__invoke()`?

I currently had a colleague reviewing my code and he had a comment on a factory class I created. It's very simple: ...
1
vote
1answer
40 views

PHP validation class for username, email, and password

I'm relatively new to PHP OOP, currently I'm practising how to use it, however I am not really certain I'm building my classes correctly, I think perhaps I'm missing something out but I'm not entirely ...
1
vote
2answers
59 views

Merge both sql queries into one to get the performance

Currently i am using 2 queries - one for reattemptdate & one for holddate.... if we merge both queries & get the results in single query , than will it give better performance? if so how to ...
0
votes
2answers
64 views

Tracking employee data

We have hundreds of employees and for tracking each employees' data, and I am using this code: ...
8
votes
2answers
210 views

PHP Chess Version 2

For programming practice, I created a chess program in PHP (my most comfortable language). The program reads a FEN (a string with the location of all the pieces on the board) from the URL, generates ...
3
votes
1answer
49 views

PHP class that behaves like enums

I'm relatively new to PHP and one of the things I miss from other languages are enums. After looking around for some samples on how can I have somewhat similar to them, I came up with this ...
0
votes
0answers
26 views

PHP mailsend procedure with file upload using iFrame

I coded the following procedure to send an email uploading the attachments using an iframe and js callback. I have many nested if condition to avoid executing the other instructions if an error ...
3
votes
0answers
22 views

Use a pattern for fields validation

I need to validate the fields of user sent by an API. All works fine but the only one problem is that I don't like the solution is not an OOP solution. In the controller I call the service created by ...
5
votes
1answer
99 views

OOP, one class from multiple database tables

This is an OOP question and probably answerable even if you don’t have PHP knowledge. (A side note – we are learning PHP OOP and decided to create a github to hopefully help others learn this and ...
1
vote
0answers
28 views

Merging and summing multi-dimensional arrays

I've found myself today really struggling with this subject and I'm pretty sure that there must be a better way to do this. First of all my arrays have the same layout, I need to merge them and sum ...
2
votes
1answer
125 views

Send blob image using Ajax/PHP

I have an image cropper that crops the uploaded image, Before sending it to the server using PHP and AJAX. Here is a live fiddle to preview a working cropping example. Here is the code: ...