Stack Exchange Network

Stack Exchange network consists of 175 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
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

Questions tagged [php]

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

0
votes
1answer
20 views

Store a hash in a cookie to identify the user's account to keep logged in after close browser

I made a option to user choose to stay logged in even after he closes the browser. It's really simple to implement, but i'm not sure about the hash i used to identify the user that is stored in a ...
1
vote
2answers
26 views

Secure a class for an hydratation from ma form POST

I use PHP classes for managing users accounts and I wonder if what I'm doing is correct. I directly use the $_POST['form'] for hydrate ...
1
vote
1answer
39 views

Simple MySql or MySqli Class

Which one of these methods is better/safer to use? And what benefits could I get using one or other? Simple mysqli: connection.php ...
2
votes
0answers
20 views

Wordpress plugin to create page-specific categories

I would love some feedback about this very simple Wordpress plugin (my first one). It's intended to create page-specific categories (via the creation of a custom taxonomy). It's working on my ...
1
vote
2answers
53 views

Statistical methods using PHP (mean, co/variance, standard deviation, skew, correlation)

Functionality This class has a list of statistical functions such as mean, variance, standard deviation, skewness, and it works okay. These functions are applied to arrays of charts data. It is an ...
-5
votes
0answers
37 views

5 different inputs from same [on hold]

im working with laravel and i want to ask you how can i insert more then one different input data from 1 form to same table field, for example: I have that 2 migrations: ...
1
vote
0answers
36 views

Controller and Model Session handling classes (MVC OOP PHP)

Models/Session.php This file performs basic conditional checks and defines a function for each distinct action regarding Session initialization and ID regeneration. Is it OK, in this context, to ...
2
votes
1answer
25 views

Edit button toggles modal and load data from PHP using AJAX and JQUERY

I've been working on an edit/update button that will toggle a modal that looks like this: Is there a better code for this JavaScript code that I made? ...
0
votes
2answers
83 views

User interface HTML string generated using PHP

Goal This is very basic beginner script, only for prototyping, probably never to reach alpha/beta prototyping/production, is being designed/tested for performance. Its performance quality might be ...
1
vote
0answers
65 views

Commission calculation using PHP

Task is to read file(input.csv) and calculate each operations commission depending of operation type(cash_in or cash_out). I dont have any specific questions, just want overall feedback, like code ...
-4
votes
0answers
24 views

How to adding login type script [closed]

I am using PHP 7.2 and MySQLi. I have the login script. I want to improve the code add login type like 'Admin,' super', 'user' and make a type best session in an index page. I have to get two error ...
-1
votes
0answers
21 views

Azure Active Directory B2C - User flows (policies) for signin/signup and password reset [closed]

I want to integrate Multi Factor Authentication (MFA) through Azure Active Directory (AD) B2C in my website built in PHP only for authentication purpose, I checked ...
4
votes
3answers
84 views

Regex match comments and quotes

UPDATE New regex - covers escaped slashes and uses lazy qualifiers: ...
2
votes
0answers
28 views

PHP - Transforming text content according to rules then persisting to database

I have a web application where my users can upload text documents and emails into what I call Streams. A stream is like a "stack", that holds all emails / documents. My users can then add ...
2
votes
1answer
88 views

PHP Mad Libs with OOP and SQL

I've been learning PHP and I've just gotten into using OOP. Classes/objects/methods etc. My end goal is to take an old Mad libs program I did with PHP, and convert it to OOP. The gist of the project ...
0
votes
3answers
144 views

Codeigniter 3: how can I avoid repeating this chunk of code in my controllers? [closed]

I am working on a basic blog application in Codeigniter 3.1.8 and Bootstrap 4. Several entities are present in all controllers (except Login.php and Register.php): static data, categories and pages. ...
0
votes
0answers
20 views

A smarter way to build custom wordpress permastructures and keep them updated in admin?

I've done this many times.. Breafly speaking, I've got a custom post type with custom taxonomy (say products_categories), and want model single urls like this structure: ...
1
vote
1answer
123 views

PHP Laravel - Improving and refactoring code to Reduce Queries

Improve Request to Reduce Queries I have a web application, where users can upload Documents or Emails, to what I call a Strema. The users can then define document fields email fields to the stream, ...
0
votes
1answer
80 views

Updating values in a database

I'm using standard jQuery Ajax to update values in the database and reflect the result in an output. This repetition seems like bad practice and I don't know enough about jQuery to consolidate this ...
5
votes
2answers
89 views

Avoiding code repeating in RESTful APIS PHP

Since my last question related to this I have managed to create a working base and to understand how MVC works. I'm writing RESTful APIS in PHP, they serve the purpose but I see that my code is ...
3
votes
1answer
79 views

Language switch based on parameters and session state

I use this to set language session for navigation. Someone said that this switch is too cumbersome. Why? Is there an easier way? ...
2
votes
2answers
104 views

PHP - Packing widgets into the fewest number of boxes, plus minimum order quantity

The problem is this: A company supplies widgets in a set of pack sizes: 250 500 1000 2000 5000 Customers can order any number of widgets, but the following rules apply: Only whole packs can be ...
5
votes
2answers
147 views

SOLID principles breaking in interview task (file parser)

Originally asked on Stack Overflow I recently had an interview where interviewers asked me to Rewrite following code with SOLID principles. Add a new file handler (...
4
votes
2answers
91 views

Rudimentary registration and login system

I'd love for someone to review my code. It works fairly well, but I'm still getting the hang of PHP and want to make sure I've got an iron-clad system that isn't hilariously vulnerable. I'm also open ...
3
votes
1answer
63 views

PHP AJAX handler to fill an HTML table

I would like to know if this code follows recommended practices and standards for AJAX/PHP calls. Can this AJAX + PHP code be improved in terms of security, performance, etc.? ajax.js: ...
1
vote
0answers
31 views

Behat Page Object Model

I have a working solution on a training exercise that I wish to improve as I feel there is a better way to utilize the form and get to the fieldsets etc using page model. HTML: ...
1
vote
0answers
27 views

Handling Multiple Asynchronous Events

I have a web application where users can uploads image documents. Now, after a new document is uploaded into the system, it should: 1) Be optimized. (OCR) 2) Perform various rules on the OCR output....
-1
votes
2answers
48 views

Refactoring my controllers with a BaseController to remove repetitive code? [closed]

Take this controller for instance. Is there a way I can rip out the constructor and property, extend a base controller class and still have $twig? I feel like this repeitive behaviour can be removed. ...
1
vote
0answers
46 views

PHP library that can use different authentication mechanisms

I am making a library which can use different auth mechanisms. I have abstracted the code within an interface: ...
2
votes
2answers
137 views

Program that prints star pattern

I have a program that prints the star pattern. Starr Pattern is: ...
3
votes
1answer
75 views

Is it enough for PHP secure session class?

I need you help with my php session class. I can not understand, the class implements adequate work with sessions. By adequate work, I understand the security and correctness of the methods. ...
1
vote
1answer
63 views

Feeding PHP variables to a number of HTML elements

The following code works fine, however, I'm trying to simplify it. I wrote it but I'm a beginner PHP coder. I can see that most probably the use of a function or class would be better... or anything ...
1
vote
0answers
44 views

Implement versioning of a RESTful API with PHP/Slim and Apache

I want to create a RESTful API with Apache/PHP and the Slim Framework (3.x). The API should support URI-based versioning like ...
2
votes
2answers
57 views

PHP Filesystem JSON Files DB

Regarding the use of the file system as a database to simply hold JSON files. Any input on this matter from people who know will be appreciated... ...
3
votes
2answers
55 views

PHP Secure Login Scripts

I have created this login script for a website I'm making; basically I want to make it as secure as possible, but also I want it to keep users logged in for 30 minutes. For example if I've logged in ...
2
votes
2answers
71 views

Writing a ~100Kb HTML string over an MD file (number of iterations ~10K)

I have tried to write a large string (~100-120 Kb of HTML) on an md file, and am pretty sure it's not the fastest method, even though it only has to iterate ~8000-...
4
votes
2answers
166 views

Load other files (from outside public_html) under index.php

I wanted to load every page under index.php with a simple index.php?do=login For example when the link index.php?do=login or <...
1
vote
1answer
219 views

Equity data processing: Fast and/or efficient file writing using PHP

Problem This project gets the past ~20 days of an equity data (such as $AAPL, $AMZN, $GOOG) plus the current equity "quote" (which comes every 60 seconds using a free API) and estimates seven "real-...
-1
votes
1answer
76 views

Read JSON files, basic calculations and write over another JSON file

Class SectorController calculates weight coefficients for sector performances in equity exchange markets using minute data from an API (for instance, if a group of ...
-3
votes
0answers
16 views

make XML, send it, receive response

this code works as intended, copypasta and it works. as long as the proper configurations are made on your test server. ...
1
vote
0answers
39 views

updatePositions() Laravel controller method

I have been trying to implement good 'OOP' and coding standards, but I always end up with bloated controllers. How could I clean this controller method? ...
1
vote
1answer
44 views

Php how to properly connect functions with pagination

Am I doing this right? I do not know how to properly connect functions with pagination. To make everything work, I have to duplicate this variables. When I add variables to the function and to the ...
1
vote
1answer
56 views

Find same characters in 2 strings

I have a solution, which compares 2 given strings and returns the number of total matching characters. I know I haven't initialized the variables and arrays and that this (correctly) yields warnings. ...
-2
votes
2answers
101 views

Sanitizing name strings using PHP

Functionality: This method removes a list of specific terms (e.g., LLC, INC, Inc, Company, etc.) from a list of public companies names. It is part of a class that can be viewed in this link. I'd ...
2
votes
1answer
26 views

PHP Class used in Drupal 8 module

I've written a module whose purpose is to allow a user to simply add their email and click 'Save Search'. The details of the search are stored in two straight MySql tables which are not in any way ...
0
votes
2answers
100 views

Methods To Generate an HTML String using an Array in PHP

Problem Method getQuoteHTML generates an HTML string using an array returned from ...
1
vote
1answer
88 views

Import class using OOP

I'm starting to code in the OOP way, but I have doubts with the following example. I have a Product entity and I want to import & create instances of this ...
1
vote
0answers
30 views

A PHP Controller, which feels to 'array-like', in Laravel

This is a controller, which receives the validated input from a http request, then finds the assorted model and for each translation key in the received data, it will add it to the model. ...
2
votes
1answer
31 views

PDO / HASH Registration form

I just made my first registration form with password confirmation, hashing with BCRYPT and PDO. As a beginner, looking around on StackExchange, I seem to miss a lot. To keep it simple for myself, I ...
2
votes
1answer
61 views

My code get data from database using AJAX and return to view

My code get data from database using AJAX the problem is i want to filter data by month year and quarter and the code that does that is: ...