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

learn more… | top users | synonyms

0
votes
0answers
8 views

Shopping Cart Handler Class - PHP

I've written an eCommerce shopping cart handler class in PHP. Please review the code and inform me of any errors and/or badly written code and/or badly handled logics. ...
0
votes
1answer
15 views

How to filter by a value X of a given array Y with fallback?

I wrote a function that solve a special problem. But one of my 'special hardcore software engineers' told me that this is a bad solution - but he will not give me a better solution. So I ask you: What ...
3
votes
1answer
16 views

phpMailer mass mailing script

I'm working on a script that will be able to send mass e-mails. I'm using cron to run this script. I'm fetching e-mails from queue. I need to ensure that: To one e-mail will NEVER be sent more than ...
1
vote
1answer
24 views

HttpSession Wrapper Class

Are there any aspects I could improve of my HttpSession wrapper class? Other suggestions are also welcome. ...
4
votes
1answer
47 views

Sanitzing input on form submit with PHP

I was hacking around this morning and wanting to use automatically generate safe-to-use variables from $_POST. Probably not the best use of ...
2
votes
1answer
42 views

Using fewer foreach loops to bind values to parameters in PDO

I want to make a query to order by the IN clause items. I read from another thread that I can use ...
4
votes
1answer
28 views

String encryption function in admin section

I have been using this function locally to encrypt strings for example a username. If the user successfully logged in, place the encrypted username into a ...
1
vote
0answers
30 views

JSON String hashing within PHP Servers' memory

I was asked to create a code that would Hash, or store the JSON files at the PHP server per User basis. Originally, the JSON objects sat on separate server. But now they are sitting at the Web/PHP ...
3
votes
1answer
58 views

RESTful workaround

I met the RESTful ideology and I fell in love with it. However the only request methods supported by HTML forms so far are GET and ...
5
votes
1answer
42 views

Displaying styled validation messages to user

I'm new to AJAX and jQuery, Just for test I created this simple code. When the user enters their First Name and their Last Name it displays a message that says Thanks for entering everything ...
5
votes
2answers
203 views

Database Handler Class

I've written this DB Handler class. Please review it and suggest any code edits or point out mistakes and security loop holes. Please also suggest a better way to handle things, if there is a security ...
2
votes
1answer
26 views

Form data handler class

I've started to write a form data handler class in PHP. Can you please review it and point out any mistakes or logic errors, or perhaps if a method can be written in a better way? ...
2
votes
1answer
16 views

Styling and activating radio buttons on condition

I have some php code to style a button and activate it, when a specific variable is true. It's actually a radio button, styled with the bootstrap to a button. As you can see below, this is how it ...
0
votes
0answers
19 views

Unit Testing of Curl based Rest Client Library

https://github.com/andrewjwolf/payjunction-php I ran into some issues with unit testing in that getting the response body etc from the curl handle was tricky. I didn't want to necessarily use a mock ...
2
votes
2answers
58 views

Simple class, solely for setting “globals”

I'm aiming for the best and simplest way to access "global" variables set in the config file for my website. So I can use them anywhere, even inside functions It's for file versioning, and I use ...
0
votes
0answers
13 views

Managing lifecycle of entities [on hold]

I'm trying to find best structure for managing lifecycle of my entities. Let's say we have classes Component, Parameter and ...
0
votes
0answers
39 views

Is this code malicious? [on hold]

I'm working on a website and recently picked someone up to work on the php portion and I have had suspicions that he may have added malicious code to the site, he pushed a bit of php without ...
4
votes
1answer
38 views

Admin section - Secure login and authentication

After a lot of back and forth on various sites, reading articles, watching videos etc i still can not figure out the best way to secure my admin section. The ...
4
votes
1answer
57 views

Restaurant system with javascript connecting to php

I'm making a web application for a restaurant kind of type. The idea is to administrate the orders and customers with the functions such as: Make a new order Delete a order View all the orders Make ...
-3
votes
0answers
18 views

Reset password number generator [on hold]

What am I missing? It it supposed to be a reset password number generator that sends a confirmation code to your phone. ...
-2
votes
0answers
13 views

Parse error: syntax error, unexpected '}' in /home/u506124311/public_html/process.php on line 38 [on hold]

Hi Guys im receiving the followin error when I'm trying to upload a picture from the process.php Parse error: syntax error, unexpected '}' in /home/u506124311/public_html/process.php on line 38 ...
1
vote
2answers
191 views

PHP Session handling class

I've written a custom PHP session class for handling sessions across the web app. Please review the code and point out mistakes and suggest better handling techniques. ...
6
votes
2answers
271 views

Simple PHP inheritance using an abstract class

I have created simple class inheritance of an abstract class Pet which is basically the skeleton of all other children classes. ...
11
votes
1answer
200 views
+50

My final sign up controller

I've asked a couple of questions here before regarding my controller, but I think I've finally gotten to understand controllers completely, but I'll never be sure unless I get my code reviewed. I've ...
1
vote
1answer
72 views

Two implementations of website internationalization

I have attempted to create an internationalization system for my PHP framework that I'm working on. For the purpose I decided I will be using MySQL to store languages and translations. Respectively I ...
2
votes
2answers
54 views

User authentication class for basic user service

This is where I got the idea for most of the code. I think this is pretty decent. I want this reviewed for security. Any criticism is welcome. ...
6
votes
1answer
65 views

MVC Model validation callback

I have made a simple MVC framework of my own for my personal website to learn a thing or two about how this whole thing even works. I think I've got the idea, but there's one thing I'm not sure about. ...
0
votes
0answers
27 views

Ideas for multi-language system [closed]

I am open for other suggestions regarding the language system, but what I currently have planned is a string type of translation ( what Android uses ), using a database to do the job. Basically I'll ...
-2
votes
1answer
19 views

Should I contain use a variable to avoid mentioning a filename twice? [closed]

for example i'm deleting file if it exist if(file_exists('path/to/file')){ unlink('path/to/file'); } or is it better to use ...
3
votes
2answers
61 views

Create nice url with diactrics removal

Please review my class. It uses iconv() (it's probably not the best solution however I haven't found any better alternative to change unknown characters). ...
2
votes
1answer
29 views

Efficiently creating a menu consisting of multi-level structure

I was asked to modify existing code to allow multi-level page structure. Each page can have one parent, and one page can have multiple children. I will present following code. My question is is there ...
2
votes
3answers
46 views
1
vote
0answers
15 views

Effective usage of multiple joins in Eloquent dependent on variable

I have an Eloquent model that has multiple types of joins that is used to filter out different request to grab the data of movies e.g.: Actors, ...
16
votes
2answers
1k views

Using 503 page when my site is in maintenance mode

This is my code for 503 page: header.php if(getOption('maintence_mode')==1) { header("location:503.php"); exit; } 503.php ...
3
votes
1answer
47 views

Throwing an exception within a try/catch block in PHP

Is there a cleaner way to do this? ...
3
votes
3answers
176 views

A child ID getting all parent IDs

Is there any MySQL function that will optimize this code? ...
5
votes
1answer
60 views

Secure way to store passwords

Here I'm trying to develop a simple framework for my own purpose. I'm using PHP and PDO. But, I'm still worried about my password security codes. Below I have posted my codes. it stored like these in ...
4
votes
2answers
58 views

Is it a good practice to use only one database instance?

I want to ask whether is good practice to have single instance of database connection or declare new every times when we needed? I have this two designs shown in below: This is database class: ...
6
votes
2answers
1k views

My boss re-wrote my PHP/Yii controller code. Which is better?

I was recently asked to write a Question-and-Answer feature for my company's product pages using Yii 1. It was my first Yii project, and it was a little rough around the edges (Code A). However, when ...
3
votes
3answers
128 views

Complex if statements in authentication method

I had asked questions about my entire class which I'll flag for closing soon. It appeared to be a little too broad for 1 post so I chopped it up and will be asking a little more specific questions ...
1
vote
1answer
36 views

Simple autoloader, but trying to make it psr-compliat

I made this class, just to understand what PSR autloader is. I didn't want to download and use it without knowing how it works. So, the one I built is very simple, but I would like a review on how to ...
2
votes
1answer
75 views

AJAX request authentication to PHP script

Recently I started looking at my AJAX call security and found some code that uses tokens, request and referer in an attempt to authenticate the call and stop XSS and CSRF. The AJAX calls are for the ...
4
votes
2answers
54 views

Updated template class for CMS

I'm not doing too well in school, so to pass my final year, and get my degree I need to do an off-school project. The teacher chose to give me the assignment of an A grade CMS, since I've always had a ...
3
votes
1answer
45 views

Notify Property Changed

Inspired by a SO post, just as an exercise, I tried to implement a way of notifying a consumer of a class about whether a property on an object has changed or not. I'm not attempting to use this in ...
3
votes
2answers
41 views

Pagination filtering

I want to check if there is page variable (in URL) and if it is, if it's correct - it cannot be number 1 because this is default page and it should be valid int ...
0
votes
0answers
60 views

Mock user table class

I've just created my first tests using mock classes. So far my tests are running much faster and now I guess I'm solely focusing on a single class (in this case I'm testing UserTable and mocking the ...
3
votes
3answers
250 views

Get and display employee time clock data

I have been making a web page in PHP and JavaScript to take employees clock times and do some things with them so I can display them. Everything is currently working quite well, but the code looks ...
2
votes
2answers
42 views

Validation using preg_match functions

I need some improvements on my code. I did some validation by preg_match and functions. I need some special characters restrictions every field. ...
0
votes
1answer
61 views

Switching between tabs inside of a web application

I'm making a web application for the administration of a restaurant kind of type. The purpose of this application is to make customers, and the orders of those customers, which has products in it, ...