Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [php]

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

49
votes
2answers
57k views

Class for reducing development time

There are many PHP PDO classes out there, agreed. However I find they do not allow for flexibility. So I created one that helps reduce development time as little as it may be but it does the job (...
1
vote
1answer
153 views

Updating register_globals code for importing $_GET and $_POST data

I'm updating a bunch of PHP code that relies on register_globals and uses request data globally. In the process of fixing/updating I spend a lot of time writing ...
5
votes
1answer
2k views

OOP-style FizzBuzz program in PHP

I've tried to write a configurable OOP-style FizzBuzz program in PHP for learning purposes. I hope everything is quite easy to understand. What do you think of the overall architecture? Are OOP ...
3
votes
2answers
3k views

Hashing passwords in PHP

When hashing a password, I understand it is best not to use functions such as SHA1 or MD5. This function is working fine and I want to know if it can be improved to increase site security. ...
1
vote
2answers
1k views

Critique sanitized user email PHP Script

So, I have a basic 'contact us' form that i have built, and I do some jQuery checking first (that a phone number is only numbers, email address doesn't contain unneeded characters, etc), but I also ...
7
votes
1answer
1k views

Critique Request: PHP Request-Method Class

I'm working on a general Requestmethod class which sanitizes and recasts the input of users in an automatic fashion. I've also tried to do array-access in cookies. ...
6
votes
1answer
4k views

Yii exception usage

I've never used a framework before, so I wanted to see if this fairly simple scenario was done correctly or could be improved: ...
1
vote
2answers
244 views

My included in every script file

Right now I'm finishing my very first web application, and I will buy my first domain name in my life shortly. My project is about a personal website that I'm going to upload every application I ...
0
votes
1answer
125 views

contact.php file

This is my contact.php file which has only 2 functionalities: Response with the default page if it is requested by the get method Process the message posted by the ...
24
votes
6answers
2k views

Are there any open vulnerabilities in this mailer script?

I made a PHP mailer script does the basic validation of fields, return errors, else submit if all is good. But it also has a honeypot field that is not required to be filled in (I'm assuming by hiding ...
5
votes
1answer
8k views

PHP dynamic insert - mysql. Is there a better way than this?

I have a dynamic form that users can add extra fields too. The group of fields are added and the input name stays the same but gets a incremental number attached to it. So for my insert php file I ...
2
votes
1answer
772 views

How can I make this code safer against XSS attacks?

I'm not sure what I'm doing wrong, but I run the code using a Web Vulnerability software and I get a lot of XSS attacks against the code. Is there something I could do better? ...
1
vote
0answers
153 views

My included in every script file - follow-up -1

In this particular question, I need the reviewers help to judge my understanding to MVC and OOP as it was my biggest problem in my original question a month ago. I included in the question the contact ...
7
votes
2answers
4k views

Securing PHP shopping cart

I've managed to create a working shopping cart and my next concern is security, mostly about the architecture and session security. Should I make sessions somehow secure, if there's no authenticated ...
6
votes
1answer
462 views

Security of a “contact us” form

I have a form, which uses AJAX to send POST data to the following controller method: ...
4
votes
4answers
494 views

Creating an array that loops out on the frontend - Don't Repeat Yourself?

Entire Code Here Don't repeat yourself I know of the "Don't repeat yourself". Still it's getting messy in some places. The code below contains three blocks of code. They are similar in some ways ...
1
vote
1answer
4k views

Doing $_POST the right way

I am not sure if I am correctly handling $_POST data in MVC pattern: Dummy $_POST data ...
1
vote
1answer
578 views

Printing results in XML

I have been writing PHP programs in the MVC pattern for quite some time. But I am not sure if I am doing it right. For instance, I have this PHP file that prints results in XML, and I put this file ...
14
votes
3answers
8k views

PHP Login System with persistent login

I'm writing my first CMS (for personal use) and I'm trying to make it the most secure I can. This is my project structure: ...
4
votes
2answers
364 views

What would be a better way of adding the functionality to “add” a student?

I have the following Student class: ...
13
votes
3answers
7k views

Basic user registration code

My first attempt at a user registration code. Login.php defines database log in variables (e.g. Database name, Table name, etc) ...
5
votes
1answer
5k views

MVC structured REST API in PHP

This approach might be wrong or right, if you have something to add please correct me since i want to learn! The past few weeks I'v been trying to build a MVC structure REST API in PHP.And this is my ...
4
votes
2answers
5k views

Setting properties inside of a class

Instead of using multiple setter functions within a class like public function setAction() public function setMethod() etc I've been using a method from a base ...
20
votes
4answers
731 views

HTML tag encoder

library.php My own HTML tag encoder that will print HTML codes according to the input. ...
7
votes
1answer
6k views

Small PHP MVC Template

The following is a new question based on answers from here: Small PHP Viewer/Controller template I have written a small MVC template library that I would like some critiques on. The library is ...
4
votes
1answer
2k views

Extendable PDO Wrapper Class

I've created a PDO wrapper. I understand PDO could be used on it's own, and I'm reinventing the wheel as there are solutions like Laravel's Eloquent that would do a better job. I'd like advice on ...
2
votes
1answer
129 views

CodeIgniter method to get requests for superiors to approve

I'm currently working on an approval system right now using PHP (Codeigniter) and I have this method of getting all the requests according to your department group and position depth. The checking of ...
6
votes
2answers
2k views

Minimalistic mysql db class

I am really just looking to make sure I am not making any weird mistakes that could hurt me in the long run or if something seems odd in the way I imagine it to work. This code does work for the way I ...
5
votes
1answer
338 views

Router to match URL to Controller Method

I wrote a router class which accepts a URL and calls the appropriate controller method based on it. I'm a little worried about the amount of dependencies it has (eg ...
5
votes
1answer
859 views

Building a model-view-controller application in PHP

I've seen at least two recent PHP questions that would do well from a Model-View-Controller ('MVC' from here-on-out in this question) setup. Now, me, being the horrible person I am, I wanted to build ...
5
votes
1answer
420 views

In-memory data cache architecture for data transfer

I am writing a cron job to manipulate and transfer remote data. I need to cache data from a table, process it, merge with previous table, iterate the process, and eventually send the result data to ...
7
votes
1answer
941 views

Critique request: PHP cookie library

I've written a fairly small library that abstracts cookie functionality in a way that mimics working with a database model. The repository is on bitbucket and the code is small enough to embed here: ...
7
votes
1answer
2k views

Am I using PHP Mcrypt the right way?

I have written a small wrapper class for using PHP Mcrypt for encrypting and decrypting text data. This class generates a salt for hashing the key and encrypts the given data with the generated key ...
6
votes
4answers
338 views

Iteration of password hashing in PHP

I'm trying to improve the security for my backend: ...
5
votes
2answers
821 views

Passing $_POST from view to model in MVC

I am building my own MVC structured project to learn the concepts of MVC and I need to pass $_POST variables from my view (which is a login form) to the model. Down below is my approach but I wonder ...
5
votes
2answers
8k views

User class design

Explained what I'm doing in the comments: ...
5
votes
1answer
143 views

Email Controller

I'm developing a Social Engineering Awareness Training Application. This is the focus of my thesis for my undergraduate degree. This will be a multi-part review request, however, if you want to see ...
4
votes
2answers
781 views

I have a huge function filled with nested blocks

Could someone help me on how to eliminate some nested blocks or improve this code? I am concerned this will slow down my site dramatically. ...
4
votes
2answers
195 views

Validator refactored to be OO

Based on my previous post I completely re-factored my code to make it object oriented. Anything I could improve when it comes to: Object oriented code; Efficiency; Readability. Any other ...
4
votes
3answers
2k views

“fake” covariance in PHP type-hinting

Here's the situation: I've got several distinct objects, each with their own responsability and (therefore) each their own dependencies. As this is code that will be implemented in 2 existing ...
3
votes
1answer
79 views

Phishing Project Error Logging

Moving on to the next steps! Previous review was here. The idea here was to implement suggestions made by @hd/@Pimgd and then implement an effective way of tracking and logging results when an ...
3
votes
2answers
1k views

Structure of API wrapper

I'm building an API wrapper for a bookkeeping SOAP API. I have some questions regarding bast practice for structure of the wrapper and for error handling. For now i've structured it like this: ...
28
votes
3answers
2k views

Small PHP Viewer/Controller template

I have written a small template Viewer/Controller esque library that I would like some critiques on. The library is located here If you are looking for where to start, check out ...
20
votes
5answers
17k views

Calculate future date based on business days

I've written a program for calculating the future date after certain number of business days. ...
9
votes
4answers
1k views

Inserting 1 line into my SQL database

This is for adding code into my table really easily, however it will be called 2000+ times per second, so I need to know if this is the most efficient code to add a row to the database. ...
7
votes
2answers
6k views
4
votes
1answer
6k views

Repository pattern with plain old PHP object

I've been reading a lot about repository patterns these days. At first, the pattern seemed easy. Most of the examples I read over the web use an ORM like below. ...
28
votes
5answers
122k views

Modifying an array during a foreach loop [closed]

This question is always on my mind. I usually alter the array while looping through its keys, based on my gut feelings: ...
9
votes
4answers
9k views

Password checker in PHP

I have written a password checker using PHP, consisting of many if else statements. Is there any possible way to shorten this code? ...
5
votes
1answer
313 views

PHP login script

I'm hoping someone would be able to identify if my code is prone to SQL injections, and just overall see if there is anything that could be done better. This is also my first time using MySQLi ...