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
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

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

-3
votes
0answers
14 views

URL shortener - Symfony 4 [on hold]

Can you make code review of my url shortener written in Symfony 4? The more feedback, the better. https://github.com/selfmadeking/URL-shortener-Symfony-4
2
votes
0answers
25 views

Simple single-file PHP login system

This is something that I initially came up with to protect a bunch of scripts on my personal webserver, but am now planning on using with a few public projects too. ...
-2
votes
0answers
31 views

What is OOP and MVC php

I have a Project that consist of an index page that has a modal that has a form: index.php ...
2
votes
0answers
21 views

Search query to find articles on website with certain tags

I have the following search query to find pages on my website where I'd like to make as much as possible use of existing functionalities to determine relationship names and to hardcore the least as ...
1
vote
0answers
28 views

Displaying topics in a PHP forum

I am very new to PHP. I've only been using it for a few months. I'm currently attempting to build a forum and wanted feedback on some of the code I have so far. These are two files I feel like could ...
2
votes
0answers
26 views

SQL/PHP Laravel - Looping through records to find relationships

I have two tables in my database, which contains a big list of organisations. They are called orgs_main and orgs_sub. This is ...
0
votes
1answer
27 views

Retrive relation on a polymorphic model

I have a Game model that is "static". Containing game information and such, and users can comment on all games. Games model <...
1
vote
1answer
41 views

Recursive function to find the number of ways a number can be generated out of a set of numbers

I had a job interview test and the question I got was about making a function which would return the number of ways a number could be generated by adding numbers from a certain set, where any number ...
0
votes
0answers
40 views

PHP Chess Part 1 - ASCII Board & Import Position

I have been really into chess lately so I decided to program the game in PHP for practice. I want to get more comfortable with classes. Part 1 of the project is complete. I have a working ASCII board ...
-1
votes
0answers
22 views

PHP page to search a list of admins [on hold]

I've written this bit of code that allows my users to search through a list of admins. Recently I've been trying to improve my security. I'm aware of prepared statements. Is the code below ...
0
votes
0answers
37 views

When to use required params validation [closed]

I have below function in my project (in Yii2), which i am using to resize the images. ...
0
votes
0answers
66 views

Object for generating HTML for hyperlinks

I have a function that generates HTML for hyperlinks. It's arguments may be string literals or variables read from the database. An example call to this function looks like: ...
2
votes
1answer
24 views

Encoding multiple rows from prepared statement in php

I have this code that hypothetically returns multiple rows from a database and encodes them in a JSON. I am wondering if this is the best and most presentable way to do it. Note: I am using msqli ...
5
votes
2answers
56 views

National Insurance Number Validation

I'm a beginner to PHP and I've written a function that validates a U.K National Insurance Number. The function works by checking whether the given number against the format below; The National ...
0
votes
0answers
13 views

How to Loop through Times in PHP? [closed]

I have an array of data with different times in it. The code works so far, but I wanted to know if it's the most efficient way to acomplish this. Here's my code so far: ...
-1
votes
0answers
11 views

A suggestion about an uploader implementation [closed]

Basically I've got an uploader class with a constructor and store/remove_file methods. Ex. ...
0
votes
0answers
24 views
0
votes
1answer
43 views

Shuffle a string in a repeatable way

The following function is designed to accept a string of characters and an integer. The function returns a string that's a reordered version of the original string. The reordering process is ...
-1
votes
0answers
13 views

Why do I need a payment integration system like Stripe / Splash / Braintree over a bank account integration? [closed]

I have a business, selling online. Now I'm updating my software portal. My developer suggests using stripe instead of a bank account. He knows it is better but he cannot explain why. Some more ...
0
votes
1answer
67 views

PHP/MySQL login

I just wanted to ask if this is a secure code (doesn't really matter if it's optimal or not) The code ...
3
votes
1answer
52 views

Conditionally displaying a notice about free shipping in Woocommerce

I wrote PHP code to display a Woocommerce notice - "free shipping for $40 & under" only once on shop page and once on cart page, but also in cart should not be more than 40$. The code works, but ...
0
votes
1answer
39 views

PHP OOP registration with User class and singleton Database class [closed]

I created registration system with PHP. I have User class that will handle all the input and insert the user input into database, and i created Database class with Singleton pattern that will connect ...
5
votes
3answers
518 views

Counting distinct triangles that have integer-length sides

Problem: We are interested in triangles that have integer length sides, all of which are between minLength and maxLength, ...
0
votes
1answer
27 views

Should I add the “fetch_group” method to my user class or should I create a separate class for group

I have a table of users, where each user has a group (or multiple groups) he/she is part of. Currently I'm handling the users group via a Users class: ...
0
votes
1answer
45 views

Custom MVC framework

So, I've been working on a very simple MVC framework and I wanted some feedback on how it works. I've worked it slightly differently where the controllers don't need to extend the base ...
5
votes
3answers
202 views

Function for creating unique strings for urls

I wrote this function in order to create unique url's for my site. Using these urls, visitors could demo site functionality without having to create a login. The function was intended to return a ...
0
votes
1answer
43 views

Map value to color rgba

I wrote this function to map value to a color I am looking for some general feedback on how I can improve the efficiency of the function. and if there is better way to do it. ...
1
vote
1answer
28 views

Bool function in PHP to check if you run the script inside docker

I had to do a CLI script that does something, I also had to add a validation that checks if it runs inside the Docker. After a research I found a solution that people check some processes via ...
3
votes
0answers
25 views

Symfony: Encrypt ID's on postLoad event

I am building an application that is becoming some kind of social media platform. I need to work a lot with the entities ID's in the HTML and Javascript for the purpose of AJAX calls. However, for ...
2
votes
1answer
73 views

CodeIgniter method to get requests for superiors to approve

I'm currently working on an approval system right now using PHP (Codeigniter) and I have this method of getting all the requests according to your department group and position depth. The checking of ...
1
vote
0answers
45 views

PHP approval system [duplicate]

I'm currently working on an approval system right now using PHP (Codeigniter) and I have this method of getting all the request according to your department group and position depth. The checking of ...
1
vote
1answer
38 views

Updating tag contents on my page

On my application, I have a JavaScript cycle that updates tag contents on my page regularly: ...
0
votes
0answers
25 views

Insert data and view data in same view page

I am learning Laravel and am trying to perform CRUD operations. I have created a page from where I can insert data into the database table and also view all the data inserted to the same table. So the ...
1
vote
1answer
148 views

Connecting 2 databases: one for admins and one for customers

I am working with 2 databases. One for admins ('backoffice') and one for users. Account managers: Use the 'backoffice' database to manage customer accounts. Customers: Whenever a users connects ...
0
votes
2answers
80 views

PHP DRY my code

I want to DRY up my code, but i can't think of a way to do this properly, mainly because of CASE 3,I don't have any idea what to do if i have muliple field inputs (all of these are user inputs ...
2
votes
0answers
26 views

Many to many (n to m) relationship without insert duplication php

I managed to make a many to many relationship work correctly using mysql, doctrine 2 and symfony 3.4. When a new element A that contains 0 to m element Bs is inserted, the B elements that already ...
0
votes
0answers
42 views

A basic MVC with routing and login system in PHP

I started working in PHP and I wrote several things before I noticed that I'm not sure if I'm doing DI right. So, I need someone to review an example of my code and tell me what I did wrong, and I'm ...
1
vote
1answer
62 views

PHP Prepare statement shortcut class

I did some looking around and found some more topics on how to use the $stmt->bind_param function inside another function or class what means the reference variables have to be sort of passed on. With ...
1
vote
1answer
107 views

Basic object-oriented PHP login, logout, and registration scripts

I am new to OOP in general and have recently started trying to develop object-oriented PHP code instead of relying on a primarily procedural style, as this is a requirement for my studies. One part of ...
1
vote
1answer
93 views

PDO Dynamic query builder

I'm trying to improve my php oop programming skills. As an exercise I wrote this class that will generate and execute dynamic sql queries. I've also writed a class to call various sanitization filters ...
6
votes
1answer
95 views

Password Hashing and SQL Queries

I am new to web development and am working on a portfolio piece, so I would like to make sure I'm not creating obvious vulnerabilities. I am wondering whether there are any clear flaws in the ...
3
votes
1answer
50 views

PHP function to evaluate comparisons between two values, with debug logging

The following method works fine but it is rather verbose: ...
0
votes
1answer
32 views

PDO insert data through transaction method

I have an import books function to insert more than 5000 rows at once, I did some research and did this one but some other places I saw a different kind of methods to insert without looping and ...
0
votes
0answers
80 views

Implementing Google ReCaptcha and PHPMailer

I have a contact form that performs validation on the server side with error messages being printed by JavaScript. I am curious if my implementation of Google ReCaptcha is correct, since my other ...
0
votes
1answer
45 views

insert multiple tag

I have 3 tables such as books, tags, book_tags. my objective is to insert books info along with tags (tags can be multiple or single). I have two methods one is insert books info 1st and then add tags ...
2
votes
1answer
73 views

Model database for contract renewal

I have made a contract renewal system in Symfony and Doctrine, and it works, but I think it can be improved, but I make too many requests to the database. These are my models: ...
1
vote
0answers
29 views

Dependancy Container

I'm currently creating my own microframework for learning purpose and I want to make it more powerful by providing a way to register classes and instantiate them (once) only when needed. So here is my ...
-5
votes
1answer
59 views

Best practice if statment [closed]

Which is good to use and why? if ($a == 3) { //do something } Or if (3 == $a) { //do something }
2
votes
1answer
56 views

PHP Template: Image file upload handler

I'm trying to develop some templates for common PHP tasks I've been dealing with. One of which is a general image file upload handler. So far I'm using the following reusable code which seems to be ...
1
vote
1answer
45 views

HTML file with a submit form

I have an HTML file that contains a submit form, which asks the users the fill in their personal info: then it will post and store into the DB by method of PHP SQL: ...