Questions tagged [php]

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

Filter by
Sorted by
Tagged with
2
votes
0answers
10 views

Query WordPress database, returning an array of rows

This is one of my first attempts at querying the WordPress database for data, and some my first PHP code ever, so please bear that in mind when commenting. It is supposed find data between two dates, ...
-2
votes
0answers
16 views

Post request in React app to PHP file in Apache server on localhost [closed]

I am creating simple app for fetching icos and firm names from one site. I have this project already done with JQuery and now I am trying to learn React and do the same in it. First part of this ...
1
vote
1answer
12 views

Validator and Sanitizer for HTML 5 attribute regex according to current HTML living standard

According to https://html.spec.whatwg.org/multipage/syntax.html#attributes-2 an HTML 5 attribute name is defined like this: Attribute names must consist of one or more characters other than controls, ...
-1
votes
0answers
32 views

Server-side form validation [closed]

I am validating a submitted form. My HTML code: ...
6
votes
3answers
126 views

Is my website's PHP registration system secure?

I would like to know if my registration system is secure. I'm not sure if it is secure, as I'm new in development, and I'm afraid that the system is flawed Also, I'm not experienced in object oriented ...
5
votes
2answers
152 views
+100

Class showing a format similar to var_dump RC5 Version

Some methods of this library require some improvements (see this description): In the constructor I am trying to create the possibility that the user modifies the ...
0
votes
1answer
43 views

Switch statement decreases adaptability of a function

Below you can see a class and a function. The class is just an dummy entity. The functon has a switch statement. That switch statement calculates the tax by to a predefined hardcoded string, and I don'...
1
vote
2answers
60 views

Router and solid principle

I would like to know if my Routing system respects the solid principle ? The system is simple, Router class contains the routes and returns the correct route and Route class represents a route, ...
0
votes
0answers
11 views

Facebook Login with JS and validate with PHP - Secure?

I am using Facebook's Javascript SDK for the login, and I am validating it with PHP Graph SDK v5.x Here is the JS: ...
3
votes
1answer
75 views

PHP: Simple SQL query builder

I've been lucky enough to get my first job as a junior PHP developer. I am concerned I'm not good enough. I would like to brush up on my coding skills and get as much constructive criticism as I can. ...
1
vote
1answer
40 views

Converting multi-dimensional array into row data

Input: ...
2
votes
1answer
48 views

REST API in clean PHP

I tried to create REST API in PHP because I would like to learn the basics before I will start use frameworks to create apps. I created a Model with CRUD methods which can be used in every model to ...
2
votes
1answer
46 views

Upload Image From URL via PHP (In a safe way)

I'm trying to make a simple code to upload an image directly from a url. However I have concerns about the safety of my code since a user can submit any url. How I can make it more safe? All the good ...
4
votes
3answers
100 views

PHP script that returns an error message based on what $_POST parameters are missing

I have a script that checks if the specified set of $_POST variables are supplied and not empty and returns an error string that is human readable. Here's my code: <...
1
vote
0answers
43 views

Using Reflection in Calling Method from URL parameters in MVC [closed]

Currently I am working on a simple MVC framework of mine. So my Core library loads the controller and method based on the URL with the given parameters. This happens in the following way: ...
-1
votes
2answers
91 views

My Script Inserts users into a database and hashes the password, I need to know how to prevent SQL injection with Procedural-Oriented MySQLi [closed]

My script works but I just want to know how I can protect myself from SQL injection with Procedural Oriented MySQLi. Most of the tutorials are about Object-Oriented MySQLi and I'm not familiar with it ...
6
votes
2answers
96 views

Password reset system in PHP

What I try to achieve I need to create a secure forgot password reset system. I am especially worrying about the security of this code and how to further improve it. Here's my code: ...
3
votes
1answer
61 views

What is the best way to use the database connection file in PHP?

I have a connection.php file into my root folder and at the bottom, I added BASE_URL ...
0
votes
2answers
64 views

Format simple array in multidimensional

I have a simple array in PHP like this : ...
0
votes
1answer
40 views

DateTime Extension for entering historical dates, i.e. birthdays

This class is intended to fulfill these requirements: Output in Y-m-d H:i:s format Allow dates to be entered as m-d-Y or m-d-y Complain if an invalid birthdate is entered (i.e., in the future or ...
0
votes
0answers
33 views

Server-side processing data table best and secure code using ajax

I am using PHP and Server-side processing data tables. I have more than 30k records on my table and I have to display the records on my page when reload so I used the below code. Is this code is the ...
-1
votes
2answers
131 views

Library to uniformly present runtime errors, exceptions, and login errors exceptions

I have this Library to control errors; I would like if you can evaluate it and make a review of the code, not about the goals of the library: Everything works for me correctly, but I am also open to ...
6
votes
2answers
410 views

Checking if an array of dates are within a date range

I created a dates_in_range() function which checks if all of the dates passed to it ($dates array) are within ...
2
votes
1answer
51 views

Extract string between first occurring set of parenthesis

I have this function and need to refactor it Please refactor the code below to make it more concise, efficient and readable with good logic flow ...
1
vote
1answer
36 views

Transform Data from JSON and CSV to another JSON format

I have 2 files wholesaler_a.csv ...
1
vote
1answer
34 views

Merge nested arrays coming from a database and a form

I need to update a nested array of settings. There are several difficulties that I managed to solve, but I'm pretty sure the code can be written much simpler. I just don't know how, which is why I'm ...
0
votes
1answer
57 views
3
votes
2answers
48 views

PHP Image Upload and Validation

I have a PHP script that uploads an image file, checks it for size, extension, and type. It then converts it to png, saves it to a folder outside the web root with a randomly generated name, then ...
3
votes
1answer
65 views

PHP JWT management base library for inclusion in larger projects

Edit: this is a base library for including in larger projects for the overall management of JSON Web Tokens (JWT) that should be compatible with other JWT libraries that share an encryption secret - ...
1
vote
1answer
33 views

JavaScript date format string to php date format string convert

Please find the following scenario, I've dynamic JS date format string from API but I am looking for the best way to convert the format that accepts in PHP date format. For now, I wrote it my own way ...
1
vote
1answer
93 views

Recieving an XSS Injection: <script>alert('xssvuln');</script>

I would very much appreciate it if someone could review the php script below for any security risks. I have a live website using shared hosting. There's a page that accepts text submissions from users....
3
votes
1answer
55 views

A lightweight CRUD, based on the Table Data Gateway pattern

In order to reduce the boilerplate code, I decided to write a lightweight database helper, based on the Table Data Gateway pattern (or at least the way I understand it) with the aim of using it for a ...
3
votes
2answers
96 views

Process POSTed data and add default string if missing

My code takes the input submitted by $ _POST, via a checkbox array. I process the array and check the sent data if there is a particular string in it, which is set ...
2
votes
0answers
67 views

Creating calendar - Speeding up PHP script

I'm working on a calendar for my office. Every people has his own column and there is a line for every day. There are some periodic date, where, for example, given people have to be working on the ...
2
votes
1answer
61 views

What good practice to use for input data with arrays?

I'm a beginner and I wonder if Is what I have created a good practice as a structure and way of working for input data processing? Is the way I wrote the index.php file a correct and secure way of ...
2
votes
0answers
33 views

Getting output of a NodeJS script in PHP [closed]

I'm using a NodeJS script to do some geo calculations using the h3.js library by Uber. the concept of getting a nodejs script result back into php is new to me. I found the following example online, ...
0
votes
1answer
53 views

Faster way to intersect arrays

I need to intersect lots of arrays with each other. Those arrays are like: ...
1
vote
1answer
58 views

Use try catch without repeating myself [closed]

Everytime I create a new controller I always use try/catch block code but I start to think if this is a good practice: ...
4
votes
2answers
149 views

A contact form with CodeIgniter and Twig

I am working on a online newspaper/blogging application with CodeIgniter 3.1.8 and Twig. I use the Twig template engine for the front-end views. I have put together this simple contact form which uses ...
4
votes
2answers
317 views

API for SQL queries with PHP PDO

I'm writing a very simple CRUD application, and I'm wondering if the way I'm using static methods throughout the code makes sense. I'd very much like to simplify ...
0
votes
0answers
19 views

How to restrict a user to use only one plugin in WordPress

I want to restrict a specific user to use only one plugin. I don't want him to see any other pages on the WordPress admin dashboard like the Plugins page, Posts, or other pages. I want to show him ...
1
vote
0answers
48 views

Is it okay to use interfaces on tests?

I have created a test, also the interfaces to be implemented for each test case based on user's role because I think it would make it easier to understand what the test case will and should do, also ...
3
votes
2answers
72 views

Adding, removing, and changing user names and passwords in .htpasswd with PHP

Some code I wrote to add, remove, and change user names and passwords in .htpasswd with PHP: ...
0
votes
2answers
27 views

Template file for creating formatted webpages

This is my working template file which I manually edit to create new properly formatted webpages for my personal website. I am interested in what advantages if any could be realized by placing the CSS ...
5
votes
1answer
132 views

function for PDO queries and return result - tested - any tips?

I write a function using PHP and MySQL, to get PDO connection, query and array of placeholders to execute query and return result. I test this function and it has good response when result for ...
1
vote
2answers
110 views

Implementing Pagination with Twig in Codeigniter 3

I am working on a online newspaper/blogging application with CodeIgniter 3.1.8 and Bootstrap 4. I have decided to add themes to it. The application is not HMVC, only MVC. I thought it was a good idea ...
2
votes
1answer
59 views

Handling user sessions on website using $_COOKIE and $_SESSION

So I am building a website. It will be only used inside our small company and it's not made for public use. What I want to achieve is the ability for user to maintain session after sign in for a ...
1
vote
1answer
83 views

Repeated DB connection at max user connections

I am trying to create class with connect to mysql database. And if there is max number of connections I want to wait and try it again. I figured out, how it can works, but I am not sure, if its the ...
1
vote
0answers
44 views

Good practice for dB connections

Is it good practice to keep the connection strings for websites in another folder outside of the site folder? For example, here is the htdocs structure. I am working on site3: ...
2
votes
0answers
86 views

Make Pagination using Ajax with Jquery, PHP, History.pushState()

Finally after a few months of searching and learning ajax with pagination php and History.pushState() I created ajax php pagination. Test page 1. Ajax(index.php) ...

1
2 3 4 5
84