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

learn more… | top users | synonyms

-2
votes
2answers
56 views

Using a lot of IF in loop WHILE to print information

I made a code and it is doing what I want. But, I would like to know if I am doing it right or in the best way. Could you please give me your thoughts about it? Thank you. ...
1
vote
1answer
44 views

Checking whether a site is up or down

I have this PHP curl function to check if a site is online or not: ...
-1
votes
0answers
18 views

PDO object directly in while-loop instead of from a variable [on hold]

I thought this should work: ...
2
votes
3answers
96 views

Checkout (page) backend

I am developing an e-commerce site and am confused about this. Customers come on the site and add some products to the cart. Customers click on the checkout link if already logged in, then will go ...
5
votes
2answers
174 views

String to Array formatting

Trying to convert, from this formatted string $filtersStr = "id:1||name:alex"; to: ['id' => 1,'name' => 'alex'] My ...
5
votes
1answer
22 views

Volunteer Signup Report - follow-up

Here is the original question. I've incorporated a lot of the feedback and I'm ready for another round of feedback and suggestions. Here is the PHP file's output. It creates a volunteer signup report ...
4
votes
0answers
89 views

Small PHP-MVC system (for personal learning / use)

I've made an "simple" / "small" MVC-like PHP system. I've used some code of an project I used before and ask questions about it back then to. The thing is, it works (the admin part to begin with), ...
2
votes
2answers
41 views

Registering usernames and passwords to a database

Here is my script that registers a user to a database. I am still very much a newbie when it comes to this topic so any guidance would be greatly appreciated. ...
0
votes
1answer
43 views

Update live table in MySQL

After populating the stock_tmp table, i'm running these SQL queries via legacy mysqli wrapper code. I don't think this code ...
-5
votes
0answers
25 views

Bad filename in the address bar when require in a form action's file [closed]

I have a form: <form method="post" action="do.php"> ... </form> In do.php I require an another php file: ...
3
votes
1answer
43 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. ...
1
vote
1answer
31 views

Handle data received by Ajax request and update database (prepared statement)

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 ...
0
votes
1answer
31 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
43 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
40 views

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

I am learning how to implement testing and try/catch statements into my code. I have a Laravel application with the following ...
3
votes
3answers
56 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
51 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
42 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
68 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
2answers
75 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 ...
6
votes
2answers
282 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
97 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
36 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
42 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
139 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
112 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
69 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
76 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
29 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
45 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
88 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
21 views

Loading script by passing path in data

Tell me if this is good or not: ...
3
votes
1answer
22 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
30 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
161 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
31 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
59 views

Website registration

Can you please tell me how to improve this code? ...
1
vote
1answer
42 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
204 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
16 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
48 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
35 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
39 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
43 views

Calculator and Formatter classes

Calculator class: ...
4
votes
1answer
43 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 ...