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.

2
votes
1answer
51 views

PHP Script - Converting string of calculations to result

So I am making a little script to convert a string of a basic maths calculation eg: "2+3+4-2+2-12+42" and it should return the total. What I have so far : <...
2
votes
1answer
55 views

Check bitstamp.net exchange rate, compare it with previous rate

I have written low quality php code, I'm not a good coder ;) Help me, please, to optimise it ;) This simple code check bitstamp.net exchange rate, compare it with previous rate and print the result. ...
1
vote
1answer
199 views

User session helper class

I write this session helper class to use it inside my projects for managing the $_SESSION variables setup after an user login or logout. It's very simple and after ...
1
vote
2answers
144 views

Creating an MVC router

I created an MVC router based on knowledge of an MVC design pattern. It will simply take a URL as a string (class/method/params...), then it will instantiate a requested class controller and call its ...
2
votes
2answers
87 views

Basic PHP template loader

For a project, I need to write a basic template manager who will be responsible to load the requested HTML or PHP template when the user clicks on a menù link. It's like a page loader since that all ...
0
votes
1answer
96 views

Writing cleaner PHP code to add additional options

I have a contact form that will perform validation on the server. Right now the form checks if the fields are empty or not. My goal is to expand it following: Check the fields for particular format, ...
1
vote
1answer
96 views

Entering users into a MySQLi database

This is a form that I want to use to enter users into a database. I used MySQLi with prepared statements. I want to make sure that I sanitized my data well. ...
1
vote
3answers
89 views
0
votes
1answer
67 views

Live search project

I have a live search project and I don't know if it's secure enough or not. I don't access it directly, but I get data by JSON so I shouldn't worry about slashes or quotes, right? The PHP code: <...
-1
votes
2answers
103 views

MySQL select between MAX-n1 AND MAX-n2

I just made this link please check this out Online Results I need to select data between 2 values from a table by using MAX because each SID has different VID. My code: ...
4
votes
1answer
290 views

PHP Application layers

I'm dealing with design layers of an application. Basically what I've so far are: Business Architecture: Client-Server Techonologies: PHP+MySQL, HTML5, JS, 3rd parties APIs My app Data Sources: ...
1
vote
0answers
37 views

design pattern for iteration php [closed]

I have this class where I can perform two loops on the same associative array, is there a design pattern that would accomplish this but with only one loop? I was thinking it would be ...
0
votes
1answer
37 views

Three class extended to one class [closed]

I built this 4 classes where the Main is the one responsible for setting and getting the variables. I am using PHP7.1. Please let me know on how to make this more amazing or maybe using trait. How ...
1
vote
1answer
58 views

Count the number of ways to make a given sum using one number from each array

I have three arrays, each of which contains only numbers. Given a target number, I need to return the number of ways I can make that sum, using exactly one number from each of the arrays. For example:...
4
votes
1answer
131 views

File uploads in Laravel - Single and multiple

I have been reading up on file uploads in Laravel, reading through the documentation and looking at best practices. In my application, I have two instances: an upload area for single files, and an ...
3
votes
1answer
56 views

PPT generator using SOLID principles

I want to use SOLID more and more but still learning, I'm improving a PPT generator and would like your help applying SOLID principles in it. That generator should print two photos per slide, first ...
2
votes
1answer
51 views

php Laravel - given a certain argument, call different function

I am building a simple calendar with recurring events. CalendarEvent.php id start_date CalendarRecurringPattern.php ...
1
vote
0answers
50 views

mysql query for color/size filter PHP takes time to load

I have an online shop on a custom PHP platform and I have some difficulties on optimising the color/size filters. At the moment it takes 30 seconds to return the query. You can test it here (the page ...
0
votes
1answer
72 views

Cross-platform MySQL database backup using mysqldump

In a Laravel (PHP framework) project, we implemented a backup feature - backing up user-generated files and database tables. What we've searched so far, the best solution in backing up mysql database ...
1
vote
1answer
76 views

return array element if it exists, otherwise null

Given is an array $array and a key $key. If the array has the key, then I want to return the value, otherwise null. Is there a ...
0
votes
0answers
90 views

Class diagram for manager and employees

I'm trying to draw an class diagram for my project management software describing the following scenario. It contains: Project Manager Employee Manager can: Create a project Change a project ...
2
votes
1answer
1k views

Fetching categories and subcategories from database

For a small blog with a limited count of categories, I wrote this code to fetch categories and subcategories from the database. I used a recursive function to call all categories and sub categories , ...
0
votes
2answers
312 views

Upload image using php 7 best practices to make it secure

I have a script that uploads an image, inserts it into database, and displays it on the home page. However it's not secure, how can i make this script more secure and make sure it allows only jpeg/...
1
vote
2answers
702 views

Image upload script more cleaner and secure using php 7 oop style.

I want to utilize namespaces and make the code on this file uploading script more secure, and cleaner looking, here is what i have so far it uploads an image and inserts it into a database. I want ...
2
votes
1answer
70 views

Simple routing system

This is my first routing system on PHP. As you can see it's very simple. Any advice or tip about it that can make it better? I want to make it better so I could use it in real websites. First I ...
0
votes
1answer
62 views

Optimize code for sending collected data to a database

I'm sending some data over to a database. There is a particular part that requires me to send a bunch of stuff all at once. It seems a little silly to me to write it this way. I feel that I could do ...
6
votes
1answer
104 views

Chart of Percentage questions Answered

Every day, Duga reports the number of unanswered questions and percentage of answered questions (after she calls the API endpoint /info) in The 2nd Monitor (so we ...
0
votes
0answers
48 views

PHP SQL Select statements

...
2
votes
1answer
133 views

PHP contact form script

I have created a contact form that originally did not have any mechanism for sending out the email with whatever the user inputted in the fields. I have added it in here along with ReCaptcha check. I ...
2
votes
3answers
398 views

Simple basic calculator php class

I wrote this basic calculator class using php.It will only execute the basic arithmetics operations so any suggestion for new functions add and improvements will be accepted. Thank you. ...
-1
votes
0answers
54 views

Memory management - Large amount of data

Context I created a bundle to run asynchronous actions (using RabbitMQ) from data extracted by a service named extract_rule in the bundle context. There are some definitions from documentation : An ...
2
votes
2answers
179 views

Users management php class

After a little bit of troubleshoots, I've finished this simple users registration and login class. It uses PDO to connect to a mysql database, I've tried also to ...
4
votes
1answer
142 views

Upload and database insert php function

I love to post here on codereview my code to have a feedback from developers that have more experience than me, to improve my coding skills. During these days I'm working on a webapp for a small ...
3
votes
4answers
395 views

Shift one value of array values to the beginning

Given an integer $value in the range of 1, 2, 3, I want to get an array that starts with ...
1
vote
0answers
179 views

PHP PDO user class

I'm working to implement an users management class inside an already existing project, so I wrote this simple code that will be called from a controller who is responsable to hash the password and ...
2
votes
1answer
599 views

Calculate total time minus non-business hours

Edit I noticed some negative values being calculated lately. I'm still unsure why it's happening. Investigating and will post back when I have an answer. I'm calculating the time it took a ...
3
votes
0answers
802 views

Full text search for multiple words using Laravel and MySQL

I'm using Laravel 5.6 and MySQL. I need to search multiple columns for a single word or multiple words (e.g., "camhandle", "cam handle"). The way I was originally doing it was just using ...
2
votes
3answers
170 views

Retrieve words from dictionary when they meet letter requirements

I have a set of functions that retrieve words from some arbitrary dictionary based on what letters they have. For example, this function gets words that use only the specified letters: ...
-1
votes
0answers
42 views

Generate festival calendar from database query

I'm building a calendar hour per hour for a five-day festival that has shows every 30 minutes and sometimes at the same time. I built this code that works correctly, but it's very slow to load on the ...
-2
votes
1answer
76 views

My code is contain some vulnerabilities, how can i correct it and make it better

My code works well, but i still don't think it is well written. Can someone help to improve the code so as to get rid of vulnerabilities. My php code: ...
14
votes
6answers
4k views

Palindrome checking function

I recently did a little task for fun that required me to create a class to determine if a word is a palindrome or not. I know this is quite simple, but I'd be interested to know if a real developer (I'...
1
vote
1answer
55 views

store and warehouse management class

I've already posted this PHP class few days ago when I started writing it. Now that all the methods and all the controller logics are ready, I will be ask here for some suggestions about how to ...
1
vote
0answers
46 views

Retrieve data from big xml files

I have written a code to retrieve data from xml file. It works but it is really slow. I takes about a minute. This is ok for 1 or some more xml files. But If you have to do it for 1000 it's not a good ...
3
votes
2answers
86 views

warehouse management class code

I'm writing a simple class to manage a warehouse, so it's supposed that it will use a database connection. All works fine for now, and I'm actually working to finish the UI. Since I think to be a ...
1
vote
0answers
121 views

Simple membership database and UI table design [closed]

I'm a bit unsure of the best way to tackle one requirement that I have on my project. I have one pretty straightforward task: I need to create database schema for members and their subscription status ...
1
vote
1answer
399 views

Security of User Add/Edit/Delete MySQL table

I have the following code which is working fine, however I am concerned around the security of this code and considering I am relatively new to php I was wondering whether the below code is secure? I ...
1
vote
1answer
70 views

Parser for json-like format in PHP

At work they use a format similar to JSON but without quotes that looks like this: {foo:{qux:1,quux:0}, bar:{}} The reason they don't just use json is because ...
5
votes
2answers
708 views

PHP creating username with random number

Trying to complete an add user script. Nothing out of the ordinary, however I have transitioned over to using prepared statements, and I am trying to get better at creating my own functions. ...
1
vote
1answer
52 views

PHP Iterate over Child's Child Efficiently

I have this code: ...
4
votes
1answer
137 views

Laravel UserController Design

...