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.

3
votes
1answer
36 views

PHP remote upload security

I need to upload images to a remote HTTP server from a local script. The image name format is {32-char MD5}.jpg. Server directory format is ...
0
votes
2answers
38 views

Wrapping certain elements in an array with an array with PHP

I have a function that's doing this correctly, but I feel as though this can be done (possibly) with minimal code, with recursion, but I'm just wracking my brain. Basically I have JSON that gets ...
2
votes
3answers
112 views

Simple Hangman in PHP

This is the simple game of hangman. Guess letters and six wrong letters means you're dead. This took me about 20 hours. And I learned enough to be certain I could make something better now in half ...
1
vote
1answer
72 views

Simple MVC built in PHP

I tried to make a MVC in PHP with OOP approach. Code Review this so I can understand whether am I using the best practices and can I legally call it a MVC framework or not. Also, I am going with 1 ...
2
votes
3answers
45 views

Select data from csv and make associative array

I've got a .csv file with ZIP codes containing the city and its sub-districts 67401,City 1,district_a 67401,City 2,district_b 67401,City 3,district_c 67401,City 3,district_d 67401,City 3,district_e ...
0
votes
1answer
75 views

PDO class wrapper

I'm writing one custom class for PDO connection. I want these advantages: Protect credentials: user, password ... Facilitate maintenance: facing future password changes for example Facilitate ...
2
votes
1answer
56 views

Queries to print out on the screen a list of menus

For common users I have 10 queries and for registered users I have 30 queries like this one below, only to print out on the screen the link for the querystrings, a guy said to me that I should escape ...
3
votes
0answers
19 views

Wrapper for Google_Service_Calendar as a Symfony service

My app interacts with Google Calendar. This Service wraps Google_Service_Calendar: ...
2
votes
2answers
69 views

User profile system with PHP and PDO - Conditional links for admin

I recently asked for a code review to my login system. This login system was fully directed to the user. Now I have added some code lines to print out some links related to the admin. Basically I ...
3
votes
1answer
68 views

Enhancing PHP realpath($path);

PHP realpath($path); is insufficient for some cases since it returns false on paths that dont exist on a file system. I need a function that extends realpath($path); to return even path that does not ...
1
vote
1answer
64 views

New comments after a user's last comment

Edit: I've added everything I can... I have the following query, which gets the last comment from the user in a given topic, then I check in the while loop if there are newer comments. My problem is,...
2
votes
1answer
198 views

A Class to validate password strength

What would be the best approach to write this class. This class validates 3 types of passwords, Normal Medium Strong Github Link ...
2
votes
0answers
24 views

WordPress plugin for shipping calculation

I am writing a WordPress plugin that allows shipping calculation on the product page. Originally, shipping calculation is only available in the cart. To calculate shipping costs on product page, ...
0
votes
1answer
22 views

Get chat message data from table, grouped by date

Giving the following table: ...
1
vote
0answers
47 views

Symfony controller to register and activate users

I've been in an interview some time ago. They objected my Symfony API code with following line: Too much code in controller actions. Can be moved to services to keep the business logic apart ...
2
votes
1answer
84 views

PHP + PDO - Inserting data on the table with a loop

First of all i made a simple code to insert data on my table, with the information from this code i made a loop to insert data on another table for a notification system. I'm new to PHP and i think ...
1
vote
1answer
53 views

Notification system using PHP+jQuery+Ajax

I have this code to display a counter on the side of <i class="fas fa-bell mr-3"></i>. I want to know if this code is good on security and perfomance. ...
1
vote
0answers
49 views

Laravel Controller function to return view based on user permission

I have one route that switches the routes based on the permission the user has. Here is a little example: ...
1
vote
2answers
54 views

Simple router in PHP

Before I start writing my first MVC framework, I want to improve my code quality as much as I can, can anyone give me some constructive criticism on how I can improve this? It is a simple router, ...
1
vote
1answer
50 views

Simple template engine in PHP

I tried writing my very first template engine today. I designed it to just replace variables in templates, and keep it basic for now. Can anyone give me some constructive criticism? I'm getting ...
0
votes
1answer
36 views

Performing multiple CRUD processes [closed]

I am concerned about how certain processes of an exercise or CRUD example should be implemented in a PHP document, looking for the best practices in terms of security and development techniques of ...
1
vote
0answers
18 views

WordPress plugin development - plugin-name.php file and plugin files/folders structure

I am creating my first WP/WooCommerce plugin. I was following instructions from WordPress Codex during development, but I wanted to review it here, to make sure I am on the right path. First things I ...
2
votes
1answer
44 views

PHP OOP: List management

I am trying to manage an "app list" in my app (I currently have "MS Office" app list, "Games" app list and "other" app list). lists table: ...
2
votes
1answer
93 views

Login system with password reset sent to e-mail using PHP and PDO

I really like to use PDO because it's simple and easy to make a safe query, i prepared all queries and used placeholders, i think it's safe but i'm not sure at all, and I'm thinking if i used ...
1
vote
0answers
69 views

Parse news content with PHP

I'm using PHP Readability to extract contents from news to get title, description and body like so. ...
2
votes
1answer
153 views

PHP code to insert phone number and IP address into a table if not already present

I am currently coding a PHP script that connects to a database and inserts a phone number and IP address if either item is not present in the table. I believe I have completed it and it is working but ...
-2
votes
1answer
49 views

Append to array if not empty [closed]

I want to call a series of functions to build up an array, like so: ...
1
vote
0answers
25 views

WordPress plugin for listing users

I was given an opportunity to join a WordPress contractor/freelancer website and was asked to build a plugin that would list the wordpress users in the database, allow you to filter them based on ...
0
votes
1answer
58 views

Back end validation as front end validation

I am trying to use the back end validation for front end validation and this is what I got. Maybe there is a better way to do this? If someone knows please share the knowledge. HTML: ...
2
votes
1answer
98 views

OOP and connecting to multiple databases using PDO

I'm just starting to learn OOP and I've setup a class to handle the database connections and wanted to check if I'm going about this the right way. My website is already using PDO for prepared ...
0
votes
2answers
175 views

Laravel: Export customer record as CSV

Using Laravel, I need to export some value from the DB in a CSV and then upload the CSV via sFTP or return it in a Response. I'm trying to be use S.O.L.I.D. principles but with this scenario, I'm not ...
-1
votes
1answer
60 views

Getting data from REST API (JSON), extract variables and upload those to database using MySQL [closed]

I'm working with a REST API, first time doing this and I have a working code but it's long and just looks messy to me. I just know there's a better and faster way to do it. ...
2
votes
2answers
32 views

Split all images over x amount of pages with $_GET

I would like to receive some feedback on the code I am currently using to display x amount of images on my website per ...
1
vote
1answer
62 views

Recursive trim() function to handle arrays and objects

I have come up with a recursive function which applies trim() recursively to all string members of an array/object. I don't have any specific quandaries about my ...
-2
votes
1answer
46 views

Adding additional attributes to an Enum object

I have used Enum objects before in PHP as shown here. However, I often find it's a requirement to have further attributes or metadata available on the instances. I came up with the example solution ...
1
vote
1answer
86 views

Edit database content with a web page

I'm new to PDO, and I want to make sure I made this in the correct way. This way is working, but I have a feeling it's unclean. I have this input: ...
3
votes
1answer
277 views

Count days from overlapping date periods with Carbon

I had to calculate the total number of days from overlapping date ranges (coming from MySQL in my case) excluding weekends and here is a working version of what I did. I am looking for a cleaner ...
3
votes
1answer
268 views

Uploading and showing images securely

I've read various posts about how letting users to upload files can create vulnerabilities to your website such as a user injecting PHP code in an image. So I've created a small test project where ...
2
votes
4answers
349 views

using $_POST array to prepare PDO statement with variables

I have been developing a little, private Blog Site to make notes/ stories of pen and paper rpg games available for me and my players. This is my first project. As I am new to coding in PHP and MySQL ...
2
votes
0answers
45 views

Builder Design Pattern To Store User Information

I am new to building with design patterns. I have been working on implementing the builder design pattern in PHP. I just want to make sure I am doing it correctly. I have been following along with ...
0
votes
0answers
28 views

License Manager PHP Class

I'm workin on this code that will be a licensing class integrated with an electron app. For now it's a simple object who will generate and check for a licence stored inside the electron app folder. I ...
3
votes
1answer
42 views

Ajax table action and process

I'm trying to learn Ajax better, and I'm developing an application in CodeIgniter. The following code is working, there are no errors. But for every function and call I think I'm repeating callbacks ...
2
votes
1answer
46 views

User form validation using a POPO

I'm trying to sketch out a stripped down generic form validation example. I started by creating Plain Old PHP Objects (referred as POPOs) for form input with some classes such as a validator and html ...
4
votes
1answer
95 views

Effective to-do list in PHP and jQuery AJAX

I made this to-do list since I never seriously used jQuery (in particular way AJAX) and I need this kind of script for a project that I'm working on. Principal features: Use of a database to manage ...
0
votes
1answer
51 views
-1
votes
1answer
30 views

Laravel function to add a supplier, and associated addresses and contacts

I have a function addSupplier() that adds a supplier. Each supplier has multiple addresses and each address has multiple contacts. ...
1
vote
1answer
29 views

Displaying pagination links, maybe with links to first and last page

I've been researching if this is possible, but I've drawn a blank, I'm wondering if it's possible to optimize these for and if statements together? ...
0
votes
1answer
52 views

How I can short my code when request have many parameters

Brief: I've create simple filter in my laravel project. I'll send parameters with ajax request. Code: ...
0
votes
1answer
48 views

Simple PHP project to store inputs in MySQL and output them

As my first simple PHP project, I've created a simple project that allows you to just enter your name and two numbers, where it displays them on the page and stores them in a database. It consists of ...
1
vote
2answers
52 views

Validate array elements in PHP

$elements is an array, which may contain 'x' or 'y' keys, I want to check if they exist, otherwise assign a 0. I'm looking for a clean way to validate it. I'm new ...