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

learn more… | top users | synonyms

1
vote
0answers
13 views

Server side form validation library

Have I followed best practices for PHP development, or can this class be improved? GitHub ...
3
votes
2answers
261 views

Encrypting and decrypting passwords in PHP

I am wanting to encrypt a password and decrypt a password using PHP. Is this a safe method? ...
0
votes
0answers
9 views

Shuffle Symfony entities

I've got an object $contest which is a Symfony entity that has some other entities assigned. I can get them by ...
4
votes
1answer
40 views

Normalizing strings using PHP preg_replace and regex expressions

I needed a way to normalize nearly any given input for a configuration parameter on a dashboard. Server side code is in PHP so I wrote a test script to experiment with ...
3
votes
1answer
31 views

Recursive file copy function

I created this function and I'm unsure if it is sufficient for "real world use", because all code snippets on the net I found for recursive copy functions used functions like ...
6
votes
2answers
70 views

Age in years at a specific date

For eligibility to events I need to know the age of a competitor at a specific date. Now the thing is the date calculations are checked in two places, an online PHP app where the entries are ...
0
votes
2answers
42 views

Using a certain query field based on state

I need to be able to do a select to a table using a where clause that can use an email or phone field, depending on if they are set/not empty or not. Given this context, how can I simplify this PHP ...
1
vote
1answer
18 views

Shoping cart code using a loop to print multiple times [on hold]

This code belongs to a shopping cart which I want to print multiple times with the help of a loop. There are 9 SQL queries and I want all these queries to run at a time with the below table every ...
-4
votes
0answers
12 views

visual basic: get php Query from text box [on hold]

How can I get url Query from text box and put it line by line in richtextbox. exemple: I want to get query from textbox1.text : and put it in richtextbox or multilines textbox line by line : ...
0
votes
0answers
17 views

Casting a float into an int lacks precision [on hold]

I have this simple code : demo $float = (float)('33.30'*100); var_dump($float); $int = (int)$float; var_dump($int); And I get this result : float(3330) ...
4
votes
1answer
89 views
+50

Related links for WordPress posts

I have written the following class which is part of a pagination system in Wordpress. The class works as expected and also works as expected when used in the system. Just as background, the class ...
3
votes
2answers
91 views

Service Layer Design

I have written the following service class for my application and at the moment it only contains a single method which is responsible for carrying out the necessary actions to add a new team to the ...
1
vote
0answers
41 views

FilesSynchronizer: Synchronize local and remote filesystems

I have written a library that syncs files between two filesystems. It works fine, but I'd like some other developers to have a look over the existing code. Maybe I can optimize something. It is using ...
-3
votes
0answers
24 views

Redirect dynamic url from root to subdirectory [closed]

I need to redirect: example.com/search.php?q=keyword to: example.com/folder/search.php?q=keyword I have tried this: RewriteCond %{QUERY_STRING} q=(.*) RewriteRule ^search.php ...
7
votes
3answers
294 views

A Simple, One-Page PHP Admin Login (with prepared SQL statements)

First off, I want mention that this code works well. This is more of a request for suggestions... We're attempting to program a one-page, recursive, token-based admin shell that is safe from ...
1
vote
0answers
38 views

PHP Class for file handling and creation

This is a very simple class to handle files. It allows to access, create and modify files in the system or 2 fake files (one in memory and other similar to ...
3
votes
1answer
50 views

Checking referential integrity of a database schema

I am using PHP PDOs to parse the results I am receiving from MySQL queries against a database. I am now running into an issue with running out of allocated memory. Are there any suggestions on ...
0
votes
0answers
39 views

Smarter Boostrap Affix

The normal boostrap affix doesn't take the items natural offset top position into account, you have to manually pass it in as an attribute. This takes care of that, and accounts for the offset top ...
2
votes
1answer
84 views

Join two arrays into a single one

I put together a function to sort out values that I am getting from a curl request for different 'devices', it works as is, I am only wondering if there is an easier way to to this. ...
2
votes
2answers
45 views

MVC controller / PHP request dispatcher

My question is, can this code be refined to be more efficient? It works fine, however I've noticed a small increment in time between requesting controllers/methods and I'm not sure where this slow ...
2
votes
2answers
62 views

Validation class

Can someone help me furnish my PHP validation class? I want to reduce its size and make it easier to use. ...
1
vote
2answers
65 views

Am I correctly implementing PHP/PDO and the MVC/DAO pattern?

Context: I am working on the login module of a PHP web-application and I am trying to implement this using PHP/PDO and the DAO pattern. I would like someone to review the code below and let me know ...
0
votes
1answer
45 views

PHPMailer hack prevention / improvement

I have been in conversation with a fellow web developer on whose servers I am doing some client work. Part of the current project is to add an email sending system from a web based form to my clients ...
2
votes
0answers
30 views

Fetching player data

I would like to select some information I have stored in my MySQL DB. I have 2 tables gameTable and playerTable. Now I want to get the gameTable and get the names and levels of these players. How do ...
2
votes
2answers
65 views

Verbose mailing function

I have multiple forms that do the same thing, send an email. As of this moment I have 3 forms that send mail. They vary only by number of inputs. One requires just an email. Another requires a name ...
2
votes
1answer
69 views

Class method to insert a record into MySQL

I'm just starting out using OOP; classes and methods etc. I've been looking around for some PDO classes/wrappers out there, but there's not much to choose from. So I've tried to make my own. Started ...
1
vote
1answer
64 views

Populating an HTML combo box by looped concatenation

This code takes the results of a database query and uses them to populate the options in a combobox on a form. Would it be better to start with an empty htmlCode ...
1
vote
0answers
26 views

Local branch update script using Git and PHP

I'm using Git and PHP to create an update script which is sync local branch and the master. It checks about new updates, and if yes, it proceeds to the Git pull request and any response got from the ...
2
votes
0answers
17 views

Limiting WP user's access to the amount of credits they have

I like this solution but maybe there is another way. My goal with this is to limit user editing to the amount of credits they have. What do you think? Here is what it does: Credits are stored as ...
1
vote
0answers
41 views

Prepared statement inside function that then return results

I've created a function that makes a query of a database table and managed to use the results in another page where the function is called. Is this approach good? ...
2
votes
2answers
83 views

Parsing a config file

I was asked to write PHP code that can be used to parse a config file on the same server (same directory as well) and output all configuration parameters, and have them all be cast to the correct ...
3
votes
1answer
30 views

Tag manipulation using DOMDocument

On our main symfony2 application at work I have had to manipulate some outputted grid fields by wrapping them in a hyperlink tag. This happens in quite a few different controllers, so I made a method ...
1
vote
0answers
47 views

Permission control on Codeigniter

The User Model ...
1
vote
2answers
73 views

Show first n elements of array, and count elements not shown

This code mimics the "likes" tooltip from Facebook. Given an array with the list of users that liked the content, it shows the first n users and displays a final item with the count of the users not ...
2
votes
2answers
83 views

Timestamp when file last modified in C#

I have the following code in PHP that appends a file path with a timestamp of when it was last modified: ...
3
votes
2answers
90 views

Email Template Parser PHP Class

This is a very basic PHP class that I am working on which will allow me to provide an HTML template in the form of a string saved to a variable or into an actual template file. I can then pass into ...
2
votes
1answer
54 views

PHP include page index.php?page=GET safety preg_replace

I found a lot of working codes to include page in page on Internet but I could not find a safe code. So I decided to create one myself. The pages will be only stored in folder /pages/ and whitelist ...
4
votes
2answers
77 views

PHP echo GET to change a CSS theme file

I have the follow code to change between different CSS theme files, I would like some reviews on it because I am sure it can be improved to be safer. ...
1
vote
0answers
45 views

Image upload handling in Laravel

I'm trying to create a handler to set the profile picture for the user. Don't worry about the validation as I will clean that up, because that's for testing purposes. This is how far I went. I'm using ...
1
vote
1answer
36 views

Filename interpreter for TV shows

I have small class which interprets TV show filenames to extract the show title and episode number. Due to the nature of the filenames, I have chosen for a cleaning approach: I clean the filename ...
1
vote
1answer
40 views

PHP PDO Database Wrapper

I'm trying to wrap my head around OOP, and am fairly new to PHP in general, so please forgive me if the following makes you cringe. I've decided to try and create a basic database wrapper using PDO. ...
3
votes
1answer
48 views

Form builder class

I am trying to learn OOP in PHP. My PHP knowledge is pretty good, but haven't tried OOP before. I'm currently building a formbuilder class. Can you take a look and tell me if this is the right way? ...
-1
votes
1answer
26 views

Human Readable filesizes

I am re-inventing the wheel and would like to lay down a comprehensive filesizes function. The only issue is that I guess bit-wise operators are more efficient but I'll be darned if I can understand ...
1
vote
1answer
25 views

PHP form to database fit for purpose

This code is intended to take input from a form and append it to a database table. The same data is sent to a separate function for subsequent mailing to the respondent. I'm self-taught and it works ...
3
votes
2answers
60 views

Getting a local file with file_get_contents

my url is like page.php?path=content/x/y/z/aaa.md. Is the following php code secure? ...
3
votes
1answer
52 views

Matchmaking system - sorting musicians by skills, genres, and location

I'm making a matchmaking system using PHP and MySQL which allows users to search through a list of musicians so that they can find people with the right skills and interests who are near them. It ...
1
vote
0answers
25 views

Decoupling payment classes

I have several classes for payment handling, I separate these classes into directories like below. Actually I'm going to use it for Laravel project but to make it simple, maybe we can talk as if it's ...
5
votes
1answer
76 views

Login Authentication

Please check this PHP script. This script is for Login authentication Some pre-defined constants to indicate the login state ...
2
votes
2answers
48 views

PHP function (in WordPress) echoing HTML

I'm really new to PHP, and a little less so in WordPress. I've created a working function that spits out some static HTML into a page template in WordPress. I'd like to know if there is a best ...
3
votes
1answer
51 views

Choosing a color based on exam score

How can I simplify this code? ...