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

learn more… | top users | synonyms

0
votes
0answers
13 views

JWT - Simple API example

I have created this fake API just because I want to learn how to use JWT. It is a simple unsigned token exchange with two methods call: login and adminPassword. I've used ...
0
votes
0answers
24 views

Compute product price that could vary based on chosen product options and the number on product modules

I am looking for a good set of design patterns to compute price. It is currently done in a Calc object, which serves as a kind of a collective library ...
-1
votes
0answers
20 views

Balancing extra backslashes while using preg_quote along with preg_replace

This is my first question on Code review, so please be lenient. I have a user defined expression like this - {geo} == "23.45" Which is evaluated at run-time, ...
0
votes
0answers
48 views

Price calculator for motors and pumps

Note This question was born in request to post more details from this question on Programmers. Since details may uncover new/different complexity, I'm asking another question here. I also will use ...
2
votes
2answers
82 views

Forgotten password / password reset

I have hand-coded a forgotten-password reset system. I am apprehensive about security issues/vulnerabilities. What part of this can be exploited or could be made more secure? forgot-password.php ...
2
votes
0answers
28 views

Security of login form using prepared statements

I've prepared a simple login form, using prepared statements to prevent SQL injections. How secure is this ? ...
2
votes
0answers
42 views

Class that generates records after performing business logic

I wrote a small class that does a database lookup and it generates a collection/Array. The Collection is resorted based on values returned from the database. Finally, the records can be retrieved ...
1
vote
0answers
12 views

Adding Wordpress Meta boxes

I am adding two custom metaboxes to the WordPress post page from a plugin. I am currently doing it with two separate instances of add_meta_boxes but this feels very ...
1
vote
2answers
75 views
0
votes
2answers
77 views

Select records between the first and last time the speed was positive

I have the following table: ...
0
votes
0answers
55 views

PHP autoload class design for a framework

I'm developing a php framework called Stack. I just created the autoload.php as follows. ...
0
votes
1answer
33 views

Compare 2 arrays and preserve the row number

Background: You have an eCommerce order of 10 products but you want to refund only 5 of them. The stock managing system needs to preserve the order of row number (orderline) when you do the returns, ...
0
votes
2answers
44 views

Custom MySQLi connector class for PHP

I have written a class that connects to a database using MySQLi and has methods for the connection itself and returns the instance of the MySQLi class. This works, but feels a little "clunky" and ...
3
votes
2answers
56 views

is_Prime() function on PHP

I tried to make an is_Prime() function in PHP. What do you think about this code? ...
2
votes
1answer
104 views

Is there a cleaner way to write this code?

The code works as it is but it's very messy. Is there a way to clean up the null checking in the if statement? ...
2
votes
1answer
57 views

Registration, Validation & Storage functions

The last time I wrote any serious code was the 90's, so a lot has changed and I am finding I am having to relearn pretty much everything. I have leaned a lot from previous posts and this is the ...
0
votes
1answer
58 views

Uploading photos: Domain Model and Repository classes

In the database, I have a table with name photographs with the following columns: id ...
1
vote
1answer
35 views

Recode algorithm for merged cells on HTML table

Is there any way to improve this algorithm maybe making it so faster avoid using foreach? Maybe with a recursion? The output of my algorithm is a table with 3 merged columns, each row will have its ...
3
votes
2answers
45 views

Classes, one responsibility principle and magic methods

I am currently building a small application that allows users to create a slideshow, each slideshow consisting of slides that are either videos or images. Although this will be relatively small at ...
1
vote
1answer
90 views

Another PHP login handler

I wrote this class to handle login sessions for a framework I'm writing for educational purposes. My major areas of concern: Style I know my style is a little contrary to most coding conventions. ...
-2
votes
2answers
43 views

Authentication check in index.php file

I am aware that this code is vulnerable for SQL injections, but I don't know how to avoid it. ...
4
votes
2answers
280 views

PHP login based on a password parameter

I'm learning PHP now, and I'm trying to find out whether or not the following code structure has any faults: ...
1
vote
0answers
22 views

Hopefully secure post love counter

Is my nonce implementation secure? I'm trying to learn security on wordpress->ajax (and later woocommerce) and with wp_create_nonce. After much struggling I managed ...
2
votes
1answer
35 views

Recursive comment function echoes HTML inside function

To display comments recursively I'm using this: ...
0
votes
0answers
21 views

Sanitization and phpmailer security

I'm trying to set up a contact form using phpmailer. Are there any security holes in my code? I want to be sure as I feel there might be some kinda exploit I may not be aware of. ...
4
votes
2answers
55 views

Wrapper class for PHPMailer

Is this a right way to use/implement an external library into a project? If it's not how do you do it? ...
2
votes
1answer
34 views

MySQL Prepared Statement - Combinging 3 seperate statements in to 1 statement

I'm currently learning MySQL about prepared statements and I was wondering if this code I've written is the most efficient way. The process: There's a query that checks a table called 'websites' ...
2
votes
1answer
27 views

Tiny function to write array or string to a file for testing with MVC, Ajax, etc

This might not even warrant posting here, but I"m enjoying it and thought I would share. ...
1
vote
1answer
32 views

Handle data insertion after validation

I have an application that has a form. Validation and data insertion works fine. However, it bulks out my controller. I've always been told skinny controllers. For example: ...
3
votes
3answers
207 views

Web page to add a notice, with some validation

I'm displaying multiple queries and if statements. In the if statement, it increments ...
7
votes
1answer
53 views

RGB <-> HSL converter + hue shifting

My input is basically a .png image from the img/ directory (I figured out that I should parse it, because there is an exploit ...
4
votes
2answers
56 views

Dissecting URLs

For the request object in my PHP application, I need to dissect the URL and assign its components to my class attributes (module, controller, method and the rest are parameters). Currently, I'm doing ...
2
votes
0answers
59 views

Node.js and Redis based chat application

I have been worked on creating a chat tool similar to vk.com. Right now I have done a simple chat which requires only authentication via a PHP website and everyone can chat with each other. I used the ...
2
votes
1answer
46 views

Login/registration part of an Android application

I made some PHP files for the login/registration part of my Android application and I would like to know if it can be made safer. config.php: ...
-1
votes
0answers
34 views

Comparing two images in two ways

I would like to know if the context of the compare is just an if-else structure and not how the whole entity/interface structure ...
1
vote
3answers
54 views

Registration and Login System for Application

I am developing a social platform and currently just completed the registration and login PHP pages. The application is an android application that authenticates against a MySQL DB. I am seeking ...
1
vote
1answer
51 views

Monkey patch allowing virtual controller methods in PHP MVC application

I'm in the process of building a soon to be opensource CMS. 100% MVC. The basic idea is that a plugin should be able to add pages (read: methods) to a given controller, without needing to instantiate ...
2
votes
1answer
64 views

Separate model from DB mapper (entity manager)

I've read that it is good to separate model from DB mapper (entity manager) (but at the end, it is perhaps personal - just a matter of opinion). Anyway, if I understood correctly, I should not have ...
1
vote
0answers
57 views

A wrapper class for Telegram bot API in PHP

I wrote a wrapper class in PHP to use Telegram bot API. What do you think about it? I used this class in some projects and it doesn't have any problem but I want to know if it is optimized? ...
1
vote
1answer
60 views

PDO - configuration, database connection & and using

I'm currently reading a book and watching some tutorials about PHP with MySQL (PDO), but it is not clear where to put certain things - where to put some code, should I put the connection to the ...
2
votes
1answer
22 views

Using an instance of PDO class as global variable inside 'query' methods

I have one PHP file named database.php: ...
0
votes
1answer
30 views

Bind variables in PHP-MySQL

I am using the below code to execute a MySQL query in PHP. ...
0
votes
2answers
43 views

Creating new PHP pages (pagination)

I have a MySQL database, with a table called articles. There is a column in articles for its id, name, ...
0
votes
1answer
19 views
2
votes
1answer
44 views

Compare multidimensional arrays

I'm writing a wordpress plugin that makes changes to the admin menu. To add some context: The wordpress global $menu is a multidimensional array. Each array in ...
2
votes
1answer
57 views

Basic contact form

This code processes a basic contact form with a name, email and message. It also asks for a code to be typed in. The data is then transformed to avoid malicious placing of HTML script on the server, ...
1
vote
1answer
42 views

Application Configuration in PHP

I'm learning PHP and I know too many ways to configure the application. I use this method: Folder: app config app.php db.php src class.php index.php ...
-1
votes
1answer
29 views

Better way to validate user input in cakephp

I'm trying to find a way to make my code easeier to read, so i found that major part of the code is validation trough if, ifelse: ...
2
votes
1answer
33 views

My library for 2 dimensional shapes

This is my first OOP PHP library and wanted to get advice on how I can improve what I wrote. This is what I needed to do: I'm also not sure on what it meant by "proportionally resize the shape up or ...
1
vote
2answers
47 views

Copying a large number of DOM elements

The aim is to duplicate and append each .grid__item into the .gallery element. The following code was my first instinct, and ...