Questions tagged [php]

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

Filter by
Sorted by
Tagged with
54
votes
2answers
59k 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 (...
2
votes
1answer
212 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 ...
35
votes
6answers
6k views

Parser written in PHP is 5.6x faster than the same C++ program in a similar test (g++ 4.8.5)

I'm absolutely dumbfounded by this. I was trying to demonstrate to myself how much faster C++ is than even modern PHP. I ran a simple CSV parsing program in both that have the same output. The CSV ...
7
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 ...
7
votes
2answers
623 views

PHP MySQLi Connection File

I have recently adjusted the way I create my mysqli connections. Initially I would include the connection file and use ...
4
votes
2answers
4k 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. ...
2
votes
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 ...
9
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. ...
8
votes
1answer
5k 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
1answer
153 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 ...
1
vote
2answers
289 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 ...
7
votes
1answer
9k 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 ...
26
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
9k 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
850 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
170 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
504 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
507 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 ...
2
votes
1answer
599 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 ...
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 ...
4
votes
2answers
369 views

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

I have the following Student class: ...
14
votes
3answers
8k 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) ...
8
votes
1answer
7k 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
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 ...
40
votes
5answers
10k views

Database connection in constructor and destructor

I am playing with different ways to do database interaction in PHP, and one of the ideas I have been playing with is connecting to the DB in the constructor and disconnecting in the destructor. This ...
22
votes
4answers
792 views

HTML tag encoder

library.php My own HTML tag encoder that will print HTML codes according to the input. ...
5
votes
1answer
429 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 ...
5
votes
1answer
500 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 ...
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 ...
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
3k 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 ...
8
votes
1answer
950 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
475 views

Iteration of password hashing in PHP

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

User class design

Explained what I'm doing in the comments: ...
5
votes
2answers
2k 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
201 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 ...
5
votes
1answer
170 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
880 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
3answers
3k 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
2answers
911 views

User class, taking on login and registration capabilities

Based on the Single Responsibility Principle, I have been looking at my User class, trying to figure out how I can break out more functionality into separate classes. But it seems like all the ...
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: ...
3
votes
1answer
81 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
1answer
118 views

Contact form with spam-prevention

Idea After a handfull of small javascript-projects, I also wanted to work a bit with php now. I decided to create a simple contact-form. Of course, I wanted it to be as spam-save as possible, so I ...
2
votes
1answer
171 views

Object-oriented PDO wrapper

So, I've recently started learning OOP in PHP and learned $this keyword. I know it's a reference to the current object. So I wrote a class and couple of functions ...
1
vote
1answer
89 views

Connect to database, handling errors

I try to handle or catch possible errors with PHP/MySQL for security reasons and would like to know if I'm doing it right. The first case, connection: I use it as a function and call it always when ...
1
vote
1answer
79 views

Should I add the “fetch_group” method to my user class or should I create a separate class for group

I have a table of users, where each user has a group (or multiple groups) he/she is part of. Currently I'm handling the users group via a Users class: ...
1
vote
1answer
71 views

Php how to properly connect functions with pagination

Am I doing this right? I do not know how to properly connect functions with pagination. To make everything work, I have to duplicate this variables. When I add variables to the function and to the ...
-50
votes
2answers
3k views

Derpifying Images

Just wondering if there was someone out there that could offer help in optimizing my script which "derpifies" images. ...

1
2 3 4 5 6