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
1answer
43 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
0answers
23 views

PHP - aria-current not display [on hold]

sorry about my English , my PHP knowledge is very poor... so , my problem.. I have a File , heard.php where have all PHP Code , here the PHP Code which I think making the problem... ...
1
vote
1answer
49 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 ...
2
votes
0answers
16 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
46 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 ...
0
votes
0answers
13 views

Get related reseller based on hotel's reseller id [closed]

Hello I have a reseller which connected multiple suppliers and each supplier has a multiple tickets and these ticket assigned and sale by hotel. Each hotel assigned one reseller. Now I want to get ...
3
votes
0answers
30 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
0answers
35 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,...
0
votes
1answer
114 views
+50

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 ...
1
vote
0answers
20 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
0answers
14 views

Get chat message data from table, grouped by date

Giving the following table: ...
0
votes
0answers
28 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
0answers
54 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
39 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
23 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: ...
0
votes
0answers
28 views

Secure PHP authentication scripts

I am using PHP and I'd like to create a secure PHP user authentication system. I want it to be as secure and as conventional as possible, especially against SQL injection and session hijacking. ...
1
vote
2answers
46 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
33 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
31 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 ...
0
votes
0answers
16 views

Proper use of $_SESSION in WordPress/PHP/AJAX example

I was wondering is this a proper way to use $_SESSION. My code is working fine, but I read a lot about how use of $_SESSION should be avoided, and how it's usage can make security holes in code, so I ...
1
vote
0answers
17 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 ...
-1
votes
0answers
22 views

PHP code to return JSON data for various kinds of charts

I need some input on how to go about refactoring my PHP code. It's a big if else that looks ugly. But its implemented with MVC so I'm finding it very hard identifying what classes should be required. ...
0
votes
0answers
34 views

My own login system for a PHP website

I have a website which has its own login system. Passwords are properly hashed, SQL statements are prepared statements and the like. I'm currently working on a few scripts which let users edit their ...
0
votes
0answers
16 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
51 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
29 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
0answers
47 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
43 views

Append to array if not empty [closed]

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

PHP - Optimise code that does a reconciliation between two arrays based on numerous fields

I build two arrays (I can't use SQL for this as I am using ROQL qhich only allows for very basic SELECT statements as shown) from a SQL query. I then want to see if any row matches in Array B based ...
1
vote
0answers
23 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
45 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
39 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
119 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 ...
0
votes
1answer
57 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
46 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
85 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: ...
2
votes
1answer
80 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
259 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
226 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
39 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
23 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
39 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
42 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 ...
1
vote
0answers
52 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
47 views
-1
votes
1answer
24 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
27 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
45 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: ...