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

learn more… | top users | synonyms

0
votes
0answers
7 views

Converts Units of Volume; optimization and improvement

I am creating a volume converter. It allows users to enter a value and select the unit to convert from and the one it will be converted into. It uses a ...
-1
votes
0answers
16 views

Is goto accettable in this situation?

I've to authorize some users to do post requests from their CMSs in order to create a new resource on my database. I've to send a JSON response containing the status of the response (successful or ...
1
vote
1answer
28 views

Storing hierarchical data into a data structure

With the following data in a table, ...
1
vote
0answers
11 views

Algorithm and PHP Class to Compare companies' information and define similarity

The task is: I get companies' information from a large CSV file and then I need to compare this information with each company in the database to know if the company is a new one or if it is already in ...
2
votes
1answer
41 views

PHP Custom $_GET checker function performance

I'm trying to follow the DRY programming philosophy and I am tired of running isset() and an if not empty statements for each ...
0
votes
0answers
17 views

Save Custom Product Kit using Web Application

How far do I break down individual tasks within a typical scenario of "Web application reacts to user input"? For example, in the case below, say a scenario is "User submits a form, causing user data ...
3
votes
1answer
49 views

Basic MVC Framework

I want to improve my skills so i startet a very basic MVC framework. Its my first MVC based Framework. Index I rewrited all requests through index.php and the ...
1
vote
2answers
27 views

Sorting and slicing array, based on another “weight” array?

I have the following input array: ...
2
votes
0answers
18 views

Write to terminal and buffer

...
0
votes
1answer
47 views

JSON Writer (PHP)

I have written a simple PHP Script that takes $_POST input and uses it to add data to a .json file. Given the security flaws in ...
5
votes
2answers
48 views

Steam Community Market Strange Part Scraper

A while back I wrote a simple little PHP script that searches the Steam community market for any TF2 strange weapons with strange parts on the first page of results for that weapon type. It works by ...
2
votes
3answers
96 views
+100

Building prefix tree from dictionary, performance issues

I'm trying to build a prfix tree. So, using the following dictionary 'and','anna','ape','apple', graph should look like this: I've tried 2 approaches: using ...
-1
votes
2answers
36 views

Find multiple keyphrases from a text

I have keyphrases abc, xyz, pqr, mno, etc. Text - " this text contains abc and mno", want to find whether text contains keyphrase string. I am looking for an efficient solution. ...
0
votes
0answers
29 views

Why my code doesn't work correctly when I put it into function? [closed]

I have a script named MakeAcatar.php which generates a avatar (something like stackoverflow's avatars) based on two parameters: size (it is size of avatar) hash ...
0
votes
1answer
65 views

PHP pages that interact with MySQL

Could someone review this PHP code to see if my pages are coded safely to not allow common attacks (SQL injection, XSS, etc.)? I would be thankful, of course, for anyone to point out other problems in ...
-1
votes
0answers
11 views

Getting the value of a input via $_POST when form is passed via AJAX [closed]

I'm not sure what I'm doing wrong. I have successfully passed a form to my PHP script via $.ajax. however i want to use 2 submits (or button) to either remove or save my form data. PHP ...
0
votes
2answers
35 views

Array that defines product information and generates the html for the product

Is there a more productive way to do this? Is my code up to standards or up to best practices? ...
1
vote
2answers
32 views

Re-sorting newsfeed based on date

Background: A client side I made recently has a component that is made from several (20+) rss-feeds, and the feeds are mashed into one using FreshRSS hosted on our servers. For some reason, FreshRSS ...
1
vote
2answers
38 views

Select random row using PDO

What do you think of this way to generate a random number from the total rows in a table? I would like to create a page that random.php precisely generates a random ID and shows it. ...
2
votes
1answer
43 views

Import data module

I have a custom module to import nodes from a .txt file. (Drupal 7). My problem is I have a lot of nodes to import and this function takes so much time. ...
1
vote
1answer
43 views

Uri Routing PHP Code

I do programing with core php & i don't want to like use any cms or mvc framework. if any handy ideas then welcome it. index.php file ...
1
vote
1answer
27 views

Forum project using OOP PHP

I've been developing a forum as my first OOP project, I've successfully built a login/registration and other functionality typical in forums. I'm looking for some guidance in terms of where to take ...
1
vote
1answer
26 views

Validation of uploading images and adding records to the database

I am doing a php project with the codeigniter framework. In my controller, I have a function that does the following. Uploads an image to the server Add a row to the database. The data would be ...
-1
votes
0answers
25 views

Secure token usage [closed]

my question is quite simple but I can't find an answer. I'm using 3rdy part API in a very simple script, I have a access token that should be added to the connection with the server, but I don't know ...
0
votes
0answers
19 views

simple fetching data and conversion into json using two different pattern

I'm trying to fetching the data and convert into json format. Some days ago I was using the mysqli but someone told me this is susceptible to SQL injections when i asked a question for code review. ...
1
vote
2answers
107 views

A find method on a Product class

The following class holds an array with products that are generated from a Json file. This is what the json file looks like ...
-1
votes
1answer
26 views

Admin panel, secure login

I ask information to you that you are much more experienced than me that I am learning. I would like to create an administrative panel with the only possibility to be logged in to the admin. Your ...
1
vote
0answers
160 views

Using a singleton for a collection of discounts to calculate?

I'm wondering if using a Singleton for a storage of discounts is the right way to go. This is because I will be looping over all added discounts in another class. client code ...
2
votes
0answers
37 views

PHP Lottery Simulator

I have a lottery simulator on my website that simulates you playing the lottery every week until your death and tells you how much you would have won or lost. It can take a custom number of balls and ...
3
votes
0answers
41 views

Fantasy league tracker for Game of Thrones

So I've just started learning about MySQL and PHP to create a fantasy league tracker for Game of Thrones for my office. I got it to technically work fine, but I think it's way clunkier than it has to ...
0
votes
1answer
34 views

Repeating HTML, minus a few class and array key differences

I feel like this code is pretty sloppy and can be accomplished in a foreach loop. But it's a bit complex using a multi-dimensional array. Can this be cleaner? You ...
1
vote
1answer
48 views

Self or this in a Class? [closed]

I have written a class that stores users activity. To store user activity, ActivityModel::record('edit', get_class(), $database->lastInsertId()); is called from ...
2
votes
1answer
115 views

Session expiration handler using PHP and jQuery

At this point i am interested to see other techniques on handling session timeouts. What are some good improvements on this script to detect when a session is no longer valid? Important definitions: ...
2
votes
2answers
46 views

User registration with Repository pattern

I have been developing a simple login registration page with PHP using the repository pattern. Following are the business rules : During registration Email must be unique. Email must be a valid ...
5
votes
2answers
81 views

Adding an item to database + JSON

Is this code good? Or is it the noobiest PHP you've ever seen? ...
2
votes
0answers
30 views

PHP routing system

I made a routing system for PHP inspired by Symfony's router composed of a few classes. First I am using Symfony's HTTP Foundations component. Then, I am emulating the classes in the routing ...
-4
votes
1answer
37 views

Am I violating the SRP in this code? [closed]

Here's a sample code that I made up : ...
3
votes
2answers
38 views

A PHP MVC controller to display a form and add an item to the database

I am creating a controller that will display a form and once the form has been submitted to store the item in the database. After the item has been stored the user will be redirected back to the main ...
1
vote
1answer
31 views

Simple bcrypt Register User and User Login using PHP - is this approach acceptable?

I am learning PHP and have been looking into a suitable way to safely store password data in MySQL. Following advice from here ...
1
vote
0answers
19 views

Send Google Cloud Messages

I wrote code which is doing query and insert inside while loop. ...
7
votes
1answer
89 views

Repository Pattern without an ORM

I'm trying to learn the Repository pattern, and I have some questions regarding my current understanding of it. All the examples I've been able to find of database repositories use ORMs, but for a ...
4
votes
2answers
66 views

Using PHP PDO to Fetch Employee Details

Introduction Hi, I am finally making the move to object oriented PHP. This has been something I have been quite reluctant to do, but I now feel that it could benefit me, and bring me up-to-date with ...
1
vote
0answers
40 views

Efficient MySQL PDO Class

I tried to create a secure and efficient PDO class.I would really appreciate your feedback to make it more production ready.Github Link ...
15
votes
4answers
2k views

PHP gaming community website

I created a gaming community website about 13 years ago. It uses PHP, SQL, HTML, and CSS, and does not use a framework or template engine. It includes features such as a login system for members, ...
3
votes
0answers
45 views

Checkout process

I'm building a checkout process where I am quite frequently making SQL connections based on user input so this is quite important. I want to know if it's well-protected from any SQL injection or other ...
0
votes
2answers
66 views

Rewrite conditional statement

I have this if else block code ...
3
votes
1answer
48 views

Uploading multiple files using a class

Below I have implemented a class that will validate and upload files based on the specified rules. ...
3
votes
1answer
63 views

Is this query vulnerable? ( MySQL Injections )

Already many days I'm documenting about the SQL Injection. I was wondering if the code I wrote is vulnerable in some of its parts. ...
-1
votes
0answers
31 views

Dynamic boostrap dashboard

I am creating dynamic dashboard, where each column of row will be considered a screen. The system picks various screens as an array that is formatted as follows: ...
1
vote
0answers
41 views

Handling errors in a PHP class to submit two forms [closed]

I am trying to handle errors in a class written in PHP and using curl. This class uses 3 functions (init, ...