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

learn more… | top users | synonyms

1
vote
1answer
12 views

Laravel user permission system

I wanted to create a simple and easy to use permissions system. The ones I've found on the Internet would need to attach every permission to a route manually (e.g. Entrust). My idea is to build a ...
0
votes
3answers
70 views

Handle multiple IF statements (working code)

I am new to PHP and was just wondering if there is a better way to write the following OR if it would make any difference to use elseif here instead of multiple ...
3
votes
2answers
37 views

Rendering nested array in a <ol> with headings

I have an array with the following structure ...
5
votes
0answers
35 views

PDO Class to help on writing SELECT statements

I made this class just for the fun of it. The idea is to make a SELECT statement really quickly. ...
-4
votes
1answer
35 views

Contact form handler with a honeypot [on hold]

I have created a php contact form and have tried to make it relatively secure. I've added a honeypot field that should be left blank, code to ensure all required fields are filled out and code to ...
1
vote
2answers
34 views

Multi-User Roles in Laravel

I am very new to Laravel. I am building a website where multiple users can have one or more roles. I have a users table and a user_roles table. Each ...
41
votes
3answers
2k views

Shielding your CodeReview on GitHub

In response to a feature-request on meta, I spent a few hours today creating the feature in php. This application adds a review shield to your GitHub repository (or wherever else you want it). It ...
0
votes
1answer
26 views

PHP session_set_saver_handler with session timeout

I have developed a class that utilises the session_set_saver_handler function so I can store sessions within my DB. The class works just as I would like. However, ...
-1
votes
0answers
50 views

Please check the code quality of the OOP beginner

I started with OOP around 1 week ago and I would like to ask you to check my code and give me some tips and advice but also tell me what I'm doing completely wrong. I'm giving you code of my ...
2
votes
1answer
37 views

Collection of $_POST data

I have a backend API that I'm sure can a refactor, but I'm not exactly sure how to avoid repetition between the store method and the ...
0
votes
0answers
16 views

Skip sending for all that return no results but still send to others [on hold]

PHP below checks person's preferences in the database then pulls relevant jobs that match their preferences from another database table. It then compiles it into an email... I can't get it to stop ...
1
vote
0answers
26 views

Favicon Downloading Script

I use this file to download favicons and was wondering why it seems to be so complicated. I've noticed that people seem to save their favicons in many different types of ways. On top of that, PHP ...
1
vote
0answers
30 views

Play Market In App Billing

I want to add In App purchases to my application. In App in test mode works great, but there is no check on their authenticity. While googling some info about making server-side of In App I found out ...
2
votes
1answer
67 views

A color class and a CRUD class for it

Is it better to have only one class color and include the functions from the second class in the 1st one? Or leave them apart? Why is one better than the other or ...
2
votes
1answer
34 views

Function to streamline PDO statements

This function arguably has little use as it's so simple, but I'm writing a web application with a lot of SQL statements littered all over the place and I thought this function might reduce code ...
2
votes
1answer
34 views

Class/Event Schedule Calendar

This is a calendar to layout an array of events/classes (from an API) in calendar format: ...
5
votes
2answers
89 views
+100

Generic Networking Class for PHP

I am in the process of writing networking code for PHP that is meant to be used in long-running PHP processes. I realize that PHP is supposedly not well suited for long-running processes, however ...
2
votes
2answers
72 views

Selecting results as a comma-separated string

The below code is working correctly, however, I am not sure if the combination of while, foreach and ...
2
votes
2answers
54 views

Upload image from Remote Server using URL

This PHP class is to allow user to enter a URL of a remote image file and have it download the image to local server. It will be used in a Markdown editor just like Stack Overflow / Stack Exchange ...
4
votes
2answers
73 views

Adjacency list with array data

I came through a question on Stack Overflow, which shows this array structure: ...
2
votes
1answer
57 views

Secured Database Insert

I've been working on a safe inserting method for a while, and I think I've found a pretty secure way to do this. Would you CRitters mind taking a look at it and maybe give me some tips to improve my ...
1
vote
1answer
34 views

Including a header file with proper content and structure

I am new to HTML and programming in general and am currently working on setting up my first website. For this I created a couple of PHP pages with a separate file for each of them and in order to ...
1
vote
1answer
34 views

Creating user accounts while avoid SQL injection attacks

I have a class that creates user accounts and to avoid SQL injection attacks, I am using the following functions to sanitize both the user name and password inputs: ...
0
votes
1answer
99 views

Countdown timer in PHP

Using PHP and jQuery, I was able to make this countdown timer. I've searched various books and obviously on Google, but couldn't find this type of approach as used by me here. I sincerely feel there ...
5
votes
1answer
122 views

Website user password verification

I have a login web page where a user enters their email and password and I need to check if: the entered email exists in the DB and the entered password matches the hashed one from the db. The ...
3
votes
1answer
44 views

Getting the HTTP client's IP

Can you please tell me whether this is a good way to get the user's IP (IPv4 or IPv6)? Does someone have a better way to do this? Please take a look at the entire code, the ...
1
vote
1answer
66 views

Reducing the size of JSON objects

I wrote a function to reduce the size of JSON objects that works simply by turning every associative array into an indexed one, and moving each property's name to the first row of the data array ...
2
votes
0answers
31 views

PHP code to connect to Facebook API

I was given a tech test for a prospective job a small game that uses Facebook API to connect a user then to guess the image. The feedback from the employer was good but they said they had to modify ...
2
votes
0answers
93 views

PHP MVC Service Layer Role

I wrote a series of questions in a previous post and a user recommended that I separate the questions. I have made the switch from procedural programming to object-oriented programming. I have ...
0
votes
0answers
16 views

Dynamic/Global Business Days Calculation

I have a problem in that I need a formula which calculates business days around the world. For example, in the UK we have 5 day weeks, but in the Middle East they have 6 day weeks. Also, perhaps we ...
4
votes
1answer
30 views

Inserting and updating data for a website monitoring app

I have created an app in which URLs stored in a database are pinged via curl to check their availability and the database is updated with the results. Two tables are updated with each fresh ping of a ...
-1
votes
2answers
42 views

Declaring multiple arrays in PHP with one line

Is it possible to declare multiple arrays in PHP in one line? ...
0
votes
0answers
34 views

Front-end login system

After some googling for about 2 days, I am here with a simple wordpress front-end login system. Please let me know if there is anything wrong with it, or if there is anything I can do, for improving ...
2
votes
1answer
72 views

Use DOM and XPath to make some changes in HTML document

I intend to make some changes in an HTML document, like remove, replace, append some nodes. I have several arrays with same structure like the following example ...
1
vote
0answers
33 views

PHP cron job for updating broadcast status

I am currently working on a re-occurring broadcast schedule. The whole idea is to setup a cron/task job that will update the broadcast flag "isLive" in a database table. Are there other options to ...
2
votes
0answers
134 views

Procedural to OOP MVC: Understanding Controllers, Models, and Service Layer

I designed a framework to make the switch from procedural to OOP design. This question will contain multiple parts I will bold each question to make reading/dissecting easier. I attempted to look into ...
1
vote
1answer
110 views

Factory dependency injector

I recently made the switch from procedural to OOP style of coding. I decided I wanted to learn how everything works before deciding to jump into a framework, follow tutorials, and becoming dependent ...
2
votes
1answer
39 views

Remote control: receiving the command

I want to create a web app that should let users remotely make a device do a variety of things simply using any other device, anywhere, without installing anything. To do that, the device which ...
8
votes
4answers
2k views

Math quiz in PHP

I coded a math quiz in PHP in which a user selects radio buttons as their answer choices. I retrieve the data of these ten radio buttons using $_POST[]; However, I ...
3
votes
0answers
42 views

Add user profile fields

I have this PHP function that adds custom user profile fields to WordPress. It saves the field through the WooCommerce form-edit-my-account.php file. I have a lot of repeated code, and would like to ...
5
votes
2answers
121 views

Slim API with 3 layer architecture

I'm new to Slim and the three layered approach I'm using below. So far I have the API, a Presentation layer (leaving out for now), a Business Logic Layer, and a Data Access Layer. The code's working, ...
5
votes
3answers
312 views

Getting 6 possible URL parameters

I am in the midst of writing a simple job board and I have the URL's filtering and working how I want, everything works - I just want to know if I can improve it, if there are any security concerns, ...
1
vote
1answer
35 views

Query containing array

I want to get the query result that contains all entries from array and some data from the DB. It's like the array is a DB table and by left join I connect the data ...
3
votes
0answers
23 views

Database syncing playback of videos

I made a website last night that allows people to sync HTML5 <video>s (playing/pausing). The way it does this is by using Ajax to run a MySQL query every 2 ...
1
vote
2answers
96 views

Return error messages for sending emails [closed]

How can I optimize this piece of code and avoid the multiple if/else call for returning error message ? ...
1
vote
0answers
40 views

Passing standard data through serviceprovider

I am using Laravel 5, and to pass the users his favorites and permalink, I edited the AppServiceProvider. I was wondering if my solution is the most reasonable ...
2
votes
2answers
44 views

PHP Autoload Class From Namespace

I wrote this function to be passed as a param in spl_autoload_register(). It autoloads PHP classes from their respective directories using their namespace, named ...
1
vote
1answer
27 views

Laravel 4 search function

I am using this code in my controller and would like to know if this is good code to use or if I can write it better, or more compact, and so on. I am just trying to learn from this. It does work, so ...
2
votes
3answers
93 views

Triangle style output, incrementing max line length

The output that I want: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 ...
2
votes
2answers
130 views

PDO wrapper with validation

After moving from mysql_ to PDO I created a PDO handling function. Basically this function takes parameters, checks them and returns end result. The thing is that I created this ~1 year ago and ...