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

learn more… | top users | synonyms

4
votes
3answers
101 views

Preparing and executing MySQL SELECT query from parameters

I am trying to make a function for Select statements. It will give result based from the parameters passed. I tried using it and it gives the results I am expecting. I know that it is still ...
0
votes
2answers
71 views

Password reset process security

Here is what the reset link looks like that goes in an email to the user: ...
7
votes
2answers
263 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 ...
2
votes
0answers
18 views

Easily registering WordPress custom post types and taxonomies

I am developing a library to easily register WordPress custom post types and taxonomies. But the problem is I can't use one instance of object because of adding the object in WordPress hooks. So ...
2
votes
1answer
40 views

PHP form called by a batch file

Just wanted to seek some advice on how can I speed up this PHP form. My batch file that calls this form is for every 1 second but it seems something in my code does the slowing. Is there any way to ...
4
votes
1answer
58 views

Check if specific key exists in 2-dimensional array

I am writing a "collision detection" in PHP and want to check if a specific "area" is still free in the two-dimensional target array. I use the following code to do that, but I think there might be a ...
1
vote
1answer
39 views

Custom error handler for PHP

I've written a custom Error handler for use in PHP. What it does is simply capture PHP errors, and logs them using Monolog. It works, but I can't help that it has too much stuff inside. I could ...
0
votes
0answers
37 views

Cross-site request forgery defense for code to count Likes

I have the following code which is supposed to insert a row into a DB table "clicks" (consisting of 1 Primary AI column "id" and another column "user" which contains the user's session ID) upon ...
4
votes
0answers
31 views

MySQLi library for handling MySQLi interactions

I wrote this class recently to better structure and handle MySQLi related interactions with PHP and would love to get some feedback. ...
4
votes
1answer
42 views

BDD in PHP, Testing search in Wikipedia with Behat and Mink (Selenium2 Driver)

I am trying to learn BDD in PHP with Behat and Mink and I am using Selenium2 driver for the same. The scenario is given on this page and is as follows: ...
4
votes
2answers
53 views

Dropdown form that shows data from 2 different tables

I am very new to this and am using php and MySQLi to create a form which will create a record in a third table. This works fine but I can't help but think that there is a way to do it with a single ...
2
votes
1answer
34 views

Taking advantage of the falsey and ineffective “” empty string

The following code snippets are academic. I was required to make a PHP generated HTML interface for a MySQL database of a movie rental store, and the requirement was filtering the displayed movies by ...
1
vote
1answer
51 views

Formatting HTML for use in a locally hosted iframe

This formats HTML for use in a locally hosted iframe so that you can manipulate the content in the iframe freely, without running into cross domain issues. It uses Goutte to retrieve the HTML. I'd ...
2
votes
0answers
23 views

Handling DB transaction in closure

I think DB transaction should be as small as possible, and close it soon. So I wrote a helper function like 'using' statement in C#. ...
1
vote
1answer
23 views

Reducing a 2D array to its longest unique series that aren't contained within any other

I have an array whose members are arrays containing strings. Each array has 5 elements, some of which may be empty but always at the end of the array. The order of the strings matters because their ...
2
votes
2answers
66 views

Image resizer and uploader

I've written an image resizer / uploader, that takes an incoming image, resizes it, and uploads it to the server, under the /usericons/ folder. However, the code ...
-1
votes
1answer
26 views

Listing blog post excerpts

I have created many sites that requires php and html. They all work fine, but I'm now thinking if all that time I do it in a wrong way. Usually, first I build the site template, then styling and last ...
8
votes
2answers
120 views

Representing IPv6 addresses with PHP per RFC 5952

I wrote the following function in PHP to represent IPv6 addresses as short as possible: ...
2
votes
2answers
65 views

A more effective approach to navigation item selection

Using Bootstrap 3 and PHP, I create my navigation bars in the following way: ...
2
votes
2answers
73 views

Dynamic PHP Form Submit Script

Below is a PHP script which dynamically finds and process all of the form elements such as inputs, textareas, dropdowns etc... then organize them into a table as shown in the image below when sending ...
2
votes
1answer
48 views

WordPress anti-spam script

This is the first PHP script I have written. It downloads and installs a plugin called "anti-spam" by using the WordPress API. It also provides an option to either delete all comments or delete the ...
3
votes
1answer
72 views

Quick CSS style generator

One day, I was thinking: Wouldn't it be nice to set a class and have all the styles defined? And that is exactly what I did: a PHP file that generates CSS with pre-defined styles. So, for fun, I ...
2
votes
1answer
61 views

Logging and getting the response in a controller

I have an action that does two things: It sends a chain of commands, and gets the response from an external API that we call wrapper. It logs the chain of ...
2
votes
1answer
43 views

Placing navigation items into an array

I am looking for better ways to write this code. At the moment it grabs a list of all navigation items and places them into an array (using PDO). However, as you can see, it is using two ...
4
votes
1answer
18 views

Youtube OAuth security

I am working with Youtube OAuth for the first time and I am not that great when it comes to security. I got the following code and would like to hear if you guys can find any security issue: ...
1
vote
1answer
34 views

Laravel time-punching database structure

I am trying to build a database structure for a time punching system. What I'm trying to figure out is if what I have is the ideal structure, or if something else exists that I'm overlooking. I want ...
4
votes
2answers
41 views

Shopping cart login and coupon code validation

I am figuring out how I could make the following query more secure: I have already used mysqli_real_escape_string but I doubt that adds much to security. I have ...
1
vote
1answer
40 views

Get InnerHTML, OuterHTML, and plain text of an element by ID or class

I do a fair amount of scraping but I am by no way a good PHP programmer. I always struggle to get the innerhtml of elements using PHP, domdocument and XPath. I have cobbled together a couple of ...
2
votes
1answer
52 views

Listing links for categories

I've developed some PHP that grabs all of a business listing's categories and then displays just the children categories. This is built on Wordpress. I'm still in the learning process and would ...
4
votes
0answers
72 views

Controller to manage athletes

I would appreciate if you could give me some advice about the code below. I am a student learning PHP programming and programming fundamentals. I have learned a lot from Stack Overflow but there are ...
4
votes
2answers
86 views

PHP shopping cart class

The following is a shopping cart class. The initial version of this was pulled from a production application. Since then it has changed a bit but I'd love to hear your feedback on this. Due to having ...
4
votes
2answers
131 views

“Remember me” functionality for a website

I have read a few SO threads to implement remember_me functionality. Steps I have followed: User clicks on login button and if passes client side validation, it goes to php Login page. First time ...
3
votes
1answer
51 views

Authentication using PDO

I'm new to PDO, so I was wondering if you guys could check over my PDO code for efficiency (and if the PHP can be improved) ...
6
votes
1answer
106 views

Routing for a Laravel 5 e-commerce site

Well, I am new here and learning laravel 5 on my own. I want to get reviewed on the following routes.php code. My question are: Have I made any mistake(s) by ...
1
vote
1answer
57 views

PHP Memento design pattern implementation

I am a self-taught programmer. I decided to learn design patterns by reading about them, and then coming up with their implementation in PHP. I know that learning would be virtually impossible without ...
-1
votes
0answers
41 views

Signup and login form security

This is my signup and login form. Is this form secure? How can I test it? Signup form ...
6
votes
2answers
114 views

PHP OOP example using animal classes

I've been reading up on OOP concepts such as: polymorphism, inheritance and encapsulation and would like to know if I am even close to using these concepts correctly. ...
2
votes
1answer
51 views

Site creation file with PHP

Here is something I've been working on today.. I been trying to determine how to build a website, that has a form, and that form allows a user to make a simple URL to give out. In the future it will ...
3
votes
1answer
45 views

PHP validation class using method dispatch

I wrote this validation class. I'm kinda new to the whole OO(PHP) style, so I don't know if my class is acceptable. I looked around at other people's validation classes, but most are huge (1k+ lines ...
3
votes
1answer
57 views

MVC'd login form

I've written this small MVC login application as an example for someone, would anyone let me know what they think of it? index ...
2
votes
1answer
81 views

Secure login system

The assignment is to create a login system secured for SQL injections and XSS. It's in PHP and I'm using PDO with prepared statements obviously. Which from my point of view should protect against the ...
1
vote
2answers
59 views

Rounding prices

I have written a PHP function that should round prices to a desired format. E.G. 1547.86456 That should be : 1547.85 OR if desired : 1547.86 The code has been written and it works under several ...
0
votes
1answer
40 views

Refactor nested foreach loop based on object property

I'm using a levenshtein matching algorithm to match a title to a filename (for anime). I either use the main show title for matching or its alternative titles (...
1
vote
3answers
61 views

Dimension comparisons for calculating image thumbnail size

I've been toying around with some code I wrote a while back, in an attempt to make it "cleaner" based on what I've read. Does anything stand out to you as bad conventions here? What are your thoughts ...
4
votes
1answer
225 views

Router for personal use

This is router I created for use, however, I wish to refactor this code and make this more robust. I would really appreciate anyone who can: Point out how to make this code more robust, clean and ...
2
votes
2answers
30 views

Developing API methods to return JSON

When developing API methods to return JSON with details I often find myself creating the following code: ...
0
votes
0answers
44 views

Building JSON array containing HTML

So, One of my companies developers wrote this. Not me. Alright, it was me. How can improve this puke? ...
1
vote
1answer
40 views

Create an associative array with values as an array from an another associative array

I have a query that returns an array or associative arrays of ids and years. It looks like this: ...
0
votes
0answers
49 views

My Users Controller

I was hoping someone could take a look at my users controller and give their feedback based one their opinions of what they think of my user's controller. As well as maybe give some ideas if any for ...
3
votes
2answers
48 views

Single MySQLI query to check for admin privileges

I have this script on top of all pages to check if user is admin otherwise we kick him. The problem is that I don't know if I am using double resources with a double query and results. Can I make this ...