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

learn more… | top users | synonyms

0
votes
0answers
15 views

Loading files or directories based on type

I am building a config class for PHP which initially loads all given config files. To add files, users should be able to provide either a single file or a directory where files can be JSON or PHP. ...
0
votes
0answers
14 views

Handle data received by ajax request and update database (prepared stmt)

I have an ajax request from a page where the user is being asked to enter their date of birth. The request url file has the code below and works all good. However, I'll be rewriting all mysql/mysqli ...
1
vote
0answers
17 views

Use header application/x-download

Zend framework 1. Physically, the file does not exist, it is created based on database. Okay so use header? ...
1
vote
2answers
35 views

Print Bootstrap 3 Tabs Component using only one foreach Loop

I'm using Bootstrap 3 to build a tab-panel component, based on information coming from the end-user. I don't like how there's a second foreach loop, but I don't know how else to print the HTML ...
0
votes
1answer
36 views

Basic sign-up method, testable and with try/catch [on hold]

I am learning how to implement testing and try/catch statements into my code. I have a Laravel application with the following ...
2
votes
3answers
47 views

Grabbing hashed password from a database

I have just discovered the beauty of prepared statements in PHP and how they protect against SQL injection. In my first time using them, I am attempting to grab a hashed password from a database and ...
3
votes
1answer
41 views

PHP password encryption algorithm

I've written a password encryption algorithm in PHP, which (I think) is not very vulnerable to rainbowtable attacks. It's just that I don't have a lot of experience with encryptions, nor PHP. But from ...
-1
votes
0answers
36 views

Simple Router class

I made a simple routing class that I like to get reviews for, mostly because I do not know how to make it SOLID, since I even made this class separate from the HTTP response, request ... for the sake ...
0
votes
1answer
56 views

MySQL JOIN to JSON array

I'm building a HTTP API and this part should return a JSON list of posts and their attached photos, like this: ...
-2
votes
0answers
25 views

I dont want to reload all the php page after dropbox selection in a div [closed]

I have a php page to present in a table, some results from DB after you select a name in a dropbox. I have a -- div id="sidebar"-- and a --div id="top_menu" --for the left menu.. After that there is ...
2
votes
2answers
73 views

Immutable subclass of a Set class

If I'm creating an immutable class from an existing class, should I override methods that mutate the property or have an instance of it and write my own methods to read from the property? I have an ...
4
votes
2answers
269 views

Password hashing and matching

I took information from a series of posts and some prior knowledge to implement the following hashing algorithm. However, there is a lot of talk about what implementations are secure and not secure. ...
1
vote
3answers
89 views

Count specific array values

I want to count specific strings from array values $array = array("report=D","report=D","report=D","report=I","report=I"); I am going to count the number of ...
5
votes
2answers
34 views

Volunteer Signup Report

I was creating a Volunteer Signup Report report in Microsoft Excel yesterday for my job and I had a moment of inspiration. What if I turned it into a website and made it dynamic? The volunteers sign ...
1
vote
1answer
37 views

Laravel controller for a grocery list

What I have is a grocery list. Once I select a grocery by ticking the checkbox, I can select an amount for that product and a unit (unit is referred to in my below code as group). Once I am done, I ...
1
vote
1answer
124 views

Simple PHP session handler class (using MySQL for session data storage)

I have tried to write a small light weighted php session handling class that use PHP's session_set_save_handler() function to overwrite the default session handling ...
3
votes
1answer
104 views

Basic login script for educational purposes

I have created a login script to demonstrate the usage of sessions in PHP. The focus is not on security, databases or encryption. The idea is to exemplify how you can use sessions to protect pages ...
-1
votes
2answers
65 views

Learning OO PHP: Am I doing this with “good practices”?

Trying to practice some OO PHP and I'm just wondering if what I'm doing is okay or not. Please tell me if there are any alarms in my method so that I can stop doing it and learn a better way. In my ...
5
votes
2answers
74 views

Password recovery program

This is a password recovery program I made, and I just want it checked out. These aren't all the files for the login and register system, only the password recovery part. The columns in the ...
3
votes
1answer
28 views

Validate profile completeness

This function checks these 6 fields for a user profile to determine if they have "completed" their profile. This just feels like it could be done better, but I can't figure how. ...
1
vote
2answers
44 views

Comparing two almost exact arrays

I have two arrays: $row $rowTwo The only difference between these two arrays are the first two keys have slightly different ...
-2
votes
5answers
84 views

What is the better way to write such code in PHP?

Is there a better way to write the below code? ...
-1
votes
0answers
18 views

Loading script by passing path in data

Tell me if this is good or not: ...
3
votes
1answer
21 views

Exception Handler on a Switch

I am working on rewriting an application in Laravel 5.1. I am new to the exception handling technique introduced in 5.0. I have overlooked taking advantage of throwing/catching exceptions frequently ...
1
vote
0answers
27 views

Chunked file upload

I'm working on an PHP application that will allow (but not require) chunked file upload (from jQuery File Upload on the front side). I tried to find appropriate code and was only able to find the ...
1
vote
1answer
48 views

Receiving an language string from file

I'm receiving an language string out of an PHP file which returns an array like this: DIR_LANG\en\home.php: ...
2
votes
2answers
160 views

Session Handling Setup

Just wanted to run through my PHP session handling and get some feedback and tips with regard to what is good (if anything!), what could be better and what is either plain wrong, or using out of date ...
1
vote
0answers
15 views

Web Scraping class schedules

I just want some advice regarding code style and best practices. Also I want to know if I'm using constant declaration and closures properly. This code is used to get the data from here ...
1
vote
1answer
25 views

Resize images in the background after upload

I have working code that uploads and resizes images. What im trying to figure out is how I can direct the browser to another page or view kind of the way facebook does, but still call the resize ...
0
votes
1answer
58 views

Website registration

Can you please tell me how to improve this code? ...
1
vote
1answer
41 views

Website register functionality

I have two links in my header: Register Login I am not creating it dynamically. If the user clicks on "login," the login form will be visible, similarly for the register form. My registration: ...
1
vote
1answer
30 views

Selecting orders submitted by a user, segregated by status

I have recently started using Laravel as my chosen framework. It is my first time using a framework. As I have made progress through my project, my controller methods have started to increase in size. ...
4
votes
2answers
196 views

Upload a photo with a unique name using PHP

I have written a script for basic uploading of a single image to a web server using PHP. This is an example that is intended for educational purposes in a basic PHP course. It does not take extensive ...
1
vote
0answers
15 views

A standard PHP script for API requests [closed]

I am setting up some PHP pages to provide API services to users (and my applications). In its most basic form, it looks like this: ...
0
votes
1answer
43 views

Laravel Controller including sort and search

I am using this code on my own personal website (my personal administration site) so it doesn't need any security and so on. I am not into learning everything about that yet, and although I do know a ...
2
votes
1answer
34 views

The correct place to implode array - MVC and Repositories concept

I am writing an application with the repositories concept in php with laravel framework. In my controller I have this method: ...
1
vote
1answer
73 views

Populating an array from a database

I have a query that populates an array from the database. In some cases, this query returns a great amount of data, (let's say for purpose of an example, 100.000 records). Each row of the database has ...
1
vote
1answer
50 views

MVC router class performance

Can you review my code? ...
3
votes
0answers
37 views

Simple administrator authentication page in PHP

I made a simple administrator page lock in PHP and I was wondering how secure it was. I want to use this script to secure administrator pages for my portfolio site but I want it to be fairly secure. ...
-1
votes
1answer
42 views

Calculator and Formatter classes

Calculator class: ...
4
votes
1answer
42 views

Generating a dynamically expandable form with multiple similar categories

Overview: Here's the look of my form. In this example, I have a form that allows dynamically adding fields in each category. Like, I can add multiple attractions like 5 attractions, same goes for ...
0
votes
2answers
32 views

Image-uploading

This currently works properly, but just takes too long. Some of the functions in it are necessary and need to remain, such as resizing, and double saves. But it probably has room for improvement. I ...
1
vote
0answers
29 views

Dynamically created Exception classes

This is a question about best practices. I have a project I am building and I have the following base Exception class: ...
2
votes
1answer
47 views

Processing document file takes forever

I'm developing a system in which users can upload their .doc file and the system will check whether the file contains certain words, and the system will tell the users whether their doc file falls ...
6
votes
1answer
129 views

mysql_safe_query()

I have been thinking of a sql-injection free implementation in dynamic languages. Here's what I came with. All the code was written just for fun and learning purposes. I would like to share it and ...
3
votes
1answer
151 views

PHP class architecture and dependency injection

Let me start off by saying I am not new to PHP or PDO, but very new to OO PHP, and have been struggling to get a firm idea of best practices in my head regarding dependency injection and structuring ...
2
votes
2answers
46 views

PDO Database Auto Table Creator

How can I do the following with less nested loops. How can I output the Table names above their corresponding tables without having to loop. Functions for returning the DB Info: ...
6
votes
1answer
78 views

Phone number extraction with regular expressions

I've been working on my own phone number extraction snippet of Regex code and I'd appreciate your feedback on it. I've tried to make it match as many different types of numbers as I knew existed in ...
2
votes
1answer
44 views

Simple DB API for inserting a record

I'm looking to make some improvements to a deliberately crude API written in PHP, it's designed to handle simple requests and talk to the DB. I have the following DB class: ...
4
votes
0answers
36 views

In-memory file system context for the behat PHP BDD testing framework

I wanted to come up with a 'utility' context to enable testing of the file system with behat. Specifically this is aimed at helping with the behavioral testing of php command line applications that ...