PHP is a widely-used, general-purpose scripting language that is especially suited for web development.
0
votes
1answer
18 views
Filename interpreter for TV shows
I have small class which interprets TV show filenames to extract the show title and episode number. Due to the nature of the filenames, I have chosen for a cleaning approach: I clean the filename ...
1
vote
1answer
15 views
PHP PDO Database Wrapper
I'm trying to wrap my head around OOP, and am fairly new to PHP in general, so please forgive me if the following makes you cringe.
I've decided to try and create a basic database wrapper using PDO. ...
3
votes
1answer
35 views
Form builder class
I am trying to learn OOP in PHP. My PHP knowledge is pretty good, but haven't tried OOP before. I'm currently building a formbuilder class. Can you take a look and tell me if this is the right way?
...
-1
votes
1answer
21 views
Human Readable filesizes
I am re-inventing the wheel and would like to lay down a comprehensive filesizes function. The only issue is that I guess bit-wise operators are more efficient but I'll be darned if I can understand ...
1
vote
1answer
19 views
PHP form to database fit for purpose
This code is intended to take input from a form and append it to a database table. The same data is sent to a separate function for subsequent mailing to the respondent. I'm self-taught and it works ...
3
votes
2answers
30 views
Getting a local file with file_get_contents
my url is like page.php?path=content/x/y/z/aaa.md. Is the following php code secure?
...
3
votes
1answer
33 views
Matchmaking system - sorting musicians by skills, genres, and location
I'm making a matchmaking system using PHP and MySQL which allows users to search through a list of musicians so that they can find people with the right skills and interests who are near them. It ...
0
votes
0answers
5 views
Handling sharp in the url (yii) [on hold]
I am trying to pass a name variable via this routing pattern.
<controller:product>/<name:[^\/]+> => 'product/view'
My aim is to get the $name in ...
1
vote
0answers
21 views
Decoupling payment classes
I have several classes for payment handling, I separate these classes into directories like below. Actually I'm going to use it for Laravel project but to make it simple, maybe we can talk as if it's ...
5
votes
1answer
48 views
Login Authentication
Please check this PHP script. This script is for Login authentication
Some pre-defined constants to indicate the login state
...
2
votes
2answers
36 views
PHP function (in WordPress) echoing HTML
I'm really new to PHP, and a little less so in WordPress. I've created a working function that spits out some static HTML into a page template in WordPress. I'd like to know if there is a best ...
3
votes
1answer
49 views
1
vote
1answer
52 views
Serializing user data to send to another API
I'm trying to improve my OOP skills in PHP. One of my projects requires me to get user info from one API and send it to another API with a different structure.
I will use a simplified situation, but ...
1
vote
1answer
35 views
PHP PDO / MySQL helper/wrapper functions
Further to my previous post for a user login script I've been learning PDO in order to migrate from mysql_* functions. As before with mysql_*, I wanted to wrap the PDO code into wrapper functions, so ...
1
vote
0answers
28 views
Time table for users
I'm working on a WordPress theme and creating a time table which will be easy to complete by users.
In the back-office, there are a checkbox for each days:
...
-2
votes
0answers
27 views
What is more efficient in constructing PHP classes? [migrated]
For each of a bunch of records from my database I instantiate a class. Inside that class I call another class.
Example
...
-1
votes
2answers
29 views
MySQL query in nested loop to get scores and averages for students
I am trying to get the scores and average for all assignments for records in a MYSQL database. The code below works but seems to take quite a bit of time to run because of the nested while loop. Any ...
5
votes
3answers
83 views
My lost password function
I'm trying to create a lost password function on my site. When a user enter their email it updates 2 columns in the users table with that email called: ...
2
votes
1answer
75 views
Get ranges from array of days
I have an array of dates as input in the form "YYYY-mm-dd"=>category_id.0 (category_id counting from 0).
...
1
vote
1answer
24 views
Multiple Wordpress metaboxes in fewer different functions
Is it possible to call multiple metaboxes in Wordpress with less duplicate functions? For instance, these are my current metaboxes (3 of them, one is a checkbox and two others are text input fields):
...
2
votes
1answer
79 views
Database Access Object Class
I learned of the Database Access Object design pattern from a friend and decided to implement it recently to my MySQL database. The code uses MySQLi to connect to the Database, and uses prepared ...
2
votes
1answer
133 views
PHP user account login with salt
I'm creating a user account login with PHP and Mysql which will be used by school teachers. To login there are 3 items required : school, username and password. This will allow for 2 of "MRSMITH" in ...
0
votes
1answer
76 views
Combine Mysql limit query
Is it possible to combine these queries into one query? I am trying to see and average all scores but also count and average just the last three based on the same grouping.
This is the main query:
...
3
votes
1answer
16 views
Virtual Airline Dispatch Generator
This Code is old and I am trying to figure out how to improve it. I am considering running the distance function in MySQL, but it is a ***** to figure out for me due to my experience with arithmetic ...
3
votes
1answer
49 views
Quick sort in PHP
Does this code show proper implementation of quick sort algorithm? If not, why? Can this code further be improved?
...
3
votes
2answers
52 views
PHP contact form
I recently had my site hacked, with the main index file being overwritten (nothing else was touched). I'm assuming they hijacked my form input.
Are there any vulnerabilities in the code or does this ...
5
votes
1answer
55 views
Script to upload CV with cookie control
I have created a script which presents a popup on every 5th pageview.
I would like to try to use just PHP cookies. However, due to the requirement of setting them before any content is output, it ...
1
vote
1answer
41 views
Interface injection and common functionality between classes
I'm trying to get my head around the OOP principles and coding my own classes. As a means to learn, I have decided to convert a couple of functions I have written in Wordpress to OOP classes. These ...
1
vote
0answers
36 views
Do I need to separate controllers by HTTP request? [closed]
I am in the process of learning proper mvc implementation. I have decided to work on a small project in my spare time and I am stuck on the controllers. I created a basic router that matches URI using ...
1
vote
2answers
49 views
Bubble sort in PHP
Does this code show proper implementation of bubble sort algorithm? If not, why?
Can this code further be improved?
...
-1
votes
0answers
34 views
2
votes
1answer
30 views
Reading and Converting XML File to Array
I'm using WordPress ( PHP Based Platform ) and I'm trying to read an external XML File, convert it into a usable array, then compare two arrays - one from the xml file and another from an options ...
2
votes
0answers
31 views
Custom backend app with require.js approach
I'm working on a small custom backend app in PHP for personal use (and practice MVC) and I thought it was a nice opportunity to try (and learn) requirejs to 'organize' my scripts and load just what ...
3
votes
3answers
87 views
PDO class and security
I have started a project in PHP with PDO and I'm almost done, but I've read somewhere that PDO escape alone is not secure and we have to consider some settings of PDP. I am a little confused about my ...
0
votes
1answer
81 views
Implementation of MVC Bootstrap & Factory
Before I get started, I feel I need to list the following.
I am not looking for an existing DI or Framework this is a personal project to shift from procedural to oop programming.
Tear this apart. ...
2
votes
2answers
38 views
Contact Form Sanitized Inputs
I have the following as my Ajax / PHP contact form on a site I am building. I have sanitized the inputs but just wanted to make sure I havent missed anything...
...
4
votes
2answers
381 views
Voting system for a website
I am currently adding a voting system to my website. Below is my voting class. I feel that it could be simplified and that there is repeated code regarding the functions, although to the best of my ...
1
vote
0answers
135 views
Laravel 5 Dependency Injecting a Repository into a controller, and depedency injecting an entity into repository
Overview::
I have a Restful API that pushes all /api/{version}/{Repository} into my ResourceV{1}Controller depending on the ...
7
votes
2answers
639 views
Preventing SQL injection by converting all characters to their ASCII values
Scenario
In order to prevent SQL injection, I'm converting every character of a string to be inserted in the database into its ASCII value before performing the query; in order to read the value of ...
2
votes
2answers
68 views
1
vote
2answers
57 views
SQL Data Fetcher for CMS
I am creating a CMS for a website, so I've added most of the functions that will fetch data from the database to a separate class. The code doesn't seem to have any bugs(Since I've tested it) but I ...
10
votes
2answers
119 views
Mission impossible: beat everyone else to the queue
Your mission, should you chose to accept it, is to beat everyone else to the review tab so you get a chance to help out.
This is a problem I've been running into lately. I go over to review tab, ...
1
vote
0answers
41 views
Create and access database connection
I'm working on an MVC project and I'm writing the code for get access to the database connection.
I have two files:
The first (PdodbLib.class.php) extends PDO:
...
3
votes
0answers
45 views
Custom session handler
I'm new to PDO and haven't been coding in a while. Is the following custom session handler industry-acceptable?
...
3
votes
1answer
54 views
A User class for visitors to register and log in to a site
I'm just looking for some feedback on my User class. The class is designed to handle users being able to register, login, and logout of the site. I'll be using it in conjunction with a forum I'm also ...
1
vote
0answers
19 views
Efficient Strip Special Characters
I have a private function in PHP that takes a given URL string and just leave the Alpha or numeric and certain punctuation left. I need the stripping of string due to having it match against ...
6
votes
2answers
192 views
Checking for existence of URL parameters
I'm busy rewriting some from my spaghetti code into OOP classes. I'm still learning OOP and very new to the concept. From help from this answer from @EliasVanOotegemto on a previous question I've ...
0
votes
1answer
54 views
API POST to save a new item in a Database via PHP & MYSQLI
Is this correct MYSQLI implementation?
IS it safe from injection?
IS the object cleanup done properly?
...
2
votes
1answer
100 views
Image upload handler with random filename generator and postprocessing
I have a function to handle image uploads. Originally, it contained a goto:
...
2
votes
0answers
28 views
Session flash class
I've created this class, for flashing variables like validation errors or success messages. But I'm not certainly sure about it.
...