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

learn more… | top users | synonyms

-1
votes
0answers
13 views

Prevent SQL INJECTION ZEND FREAMWORK 1.10 [on hold]

I am new to PHP and ZEND Freamwork 1.10. Actually the coding done three years back. Now my customer wants to secre application. So I need to to help how to prevent the sql injection the zend freamwork ...
0
votes
1answer
13 views

Resize images in the background after upload

I have working code that uploads and resizes images. What im trying to figure out is how I can direct the browser to another page or view kind of the way facebook does, but still call the resize ...
0
votes
1answer
27 views

Website registration

Can you please tell me how to improve this code? ...
1
vote
1answer
32 views

Website register functionality

I have two links in my header: Register Login I am not creating it dynamically. If the user clicks on "login," the login form will be visible, similarly for the register form. My registration: ...
1
vote
1answer
24 views

Selecting orders submitted by a user, segregated by status

I have recently started using Laravel as my chosen framework. It is my first time using a framework. As I have made progress through my project, my controller methods have started to increase in size. ...
4
votes
2answers
157 views

Upload a photo with a unique name using PHP

I have written a script for basic uploading of a single image to a web server using PHP. This is an example that is intended for educational purposes in a basic PHP course. It does not take extensive ...
1
vote
0answers
12 views

A standard PHP script for API requests [on hold]

I am setting up some PHP pages to provide API services to users (and my applications). In its most basic form, it looks like this: ...
0
votes
1answer
27 views

Laravel Controller including sort and search

I am using this code on my own personal website (my personal administration site) so it doesn't need any security and so on. I am not into learning everything about that yet, and although I do know a ...
0
votes
0answers
24 views

PHP won't connect to MySQL Database [on hold]

I'm trying to create a login/register system, though I'm having some problems adding the information to the database, here is my register.php. ...
2
votes
1answer
23 views

The correct place to implode array - MVC and Repositories concept

I am writing an application with the repositories concept in php with laravel framework. In my controller I have this method: ...
1
vote
1answer
66 views

Populating an array from a database

I have a query that populates an array from the database. In some cases, this query returns a great amount of data, (let's say for purpose of an example, 100.000 records). Each row of the database has ...
1
vote
1answer
45 views

MVC router class performance

Can you review my code? ...
3
votes
0answers
27 views

Simple administrator authentication page in PHP

I made a simple administrator page lock in PHP and I was wondering how secure it was. I want to use this script to secure administrator pages for my portfolio site but I want it to be fairly secure. ...
-3
votes
0answers
11 views

Wordpress search box not returning results [closed]

This is the code I have, however it isn't bringing back any results, does anybody have any experience in this field who may be able to help? ...
0
votes
0answers
8 views

Migrating from php5.4 to 5.5 and having trouble with a log in [closed]

Please can someone help me in guiding me in the correct direction to get this code to work ...
0
votes
0answers
14 views

Creating a custom object in PHP, that is sent to a SOAP service [closed]

I am trying to build up a customer object in PHP and then send to a asmx web service. Everything works fine except that I build an array inside the PHP. When I send it to the web-service only the last ...
0
votes
1answer
40 views

Calculator and Formatter classes

Calculator class: ...
4
votes
1answer
38 views

Generating a dynamically expandable form with multiple similar categories

Overview: Here's the look of my form. In this example, I have a form that allows dynamically adding fields in each category. Like, I can add multiple attractions like 5 attractions, same goes for ...
0
votes
2answers
28 views

Image-uploading

This currently works properly, but just takes too long. Some of the functions in it are necessary and need to remain, such as resizing, and double saves. But it probably has room for improvement. I ...
1
vote
0answers
27 views

Dynamically created Exception classes

This is a question about best practices. I have a project I am building and I have the following base Exception class: ...
2
votes
1answer
44 views

Processing document file takes forever

I'm developing a system in which users can upload their .doc file and the system will check whether the file contains certain words, and the system will tell the users whether their doc file falls ...
6
votes
1answer
112 views
+100

mysql_safe_query()

I have been thinking of a sql-injection free implementation in dynamic languages. Here's what I came with. All the code was written just for fun and learning purposes. I would like to share it and ...
-1
votes
0answers
18 views

Collection library [closed]

So i wrote this collection library for PHP and would like another pair of eyes going through the code. My main concern is that i introduced this way of executing callables passed to the Collection ...
3
votes
1answer
127 views

PHP class architecture and dependency injection

Let me start off by saying I am not new to PHP or PDO, but very new to OO PHP, and have been struggling to get a firm idea of best practices in my head regarding dependency injection and structuring ...
2
votes
2answers
38 views

PDO Database Auto Table Creator

How can I do the following with less nested loops. How can I output the Table names above their corresponding tables without having to loop. Functions for returning the DB Info: ...
5
votes
1answer
72 views

Phone number extraction with regular expressions

I've been working on my own phone number extraction snippet of Regex code and I'd appreciate your feedback on it. I've tried to make it match as many different types of numbers as I knew existed in ...
2
votes
1answer
41 views

Simple DB API for inserting a record

I'm looking to make some improvements to a deliberately crude API written in PHP, it's designed to handle simple requests and talk to the DB. I have the following DB class: ...
4
votes
0answers
36 views

In-memory file system context for the behat PHP BDD testing framework

I wanted to come up with a 'utility' context to enable testing of the file system with behat. Specifically this is aimed at helping with the behavioral testing of php command line applications that ...
6
votes
1answer
56 views

Bucketizing time (e.g., 4 min => 0-5 min)

Specification: Given a string (e.g., the content of an article), print the estimated reading time by bucketizing time into increasingly large chunks in the form "5-10 min" or "48 min-2 hr". ...
1
vote
0answers
20 views

Eloquent Scope and Normal Way

I read the documentation part of Eloquent, especially scopes: Scopes allow you to easily re-use query logic in your models. To define a scope, simply prefix a model method with scope: And so, ...
-1
votes
1answer
50 views

MySQL security in PHP

I'm creating a database class. It's part academic and part something I may show in an interview. The purpose of this method is to accept a table name as a parameter, check if the PDO Object has been ...
2
votes
1answer
56 views

Retrieving result sets from a MySQL table

This retrieves result sets from a MySQL table. The objective of this function is to correctly retrieve any number of rows (with $sql) from a MySQL table, binding ...
3
votes
1answer
57 views

Forms - Ordered fields vs. dynamic iterations

I've made about 2 forms that have a server side action using PHP. For the first one, I made a variable for every form field and mapped it to $_POST["name"]. For ...
5
votes
2answers
69 views

Identifying most recent blogXX.php file

I create blog posts as blog1.php...blog20.php...blog500.php etc and redirect users from ...
0
votes
1answer
57 views

Upload file program

I'm working on an upload file program in PHP in OOP style. I need some feedback about code. index.php ...
0
votes
0answers
33 views

Reducing execution time of an HTML parsing script

The script is intended to return an array with texts containing specific words in English and the equivalent texts in Polish from EUR-Lex - a website with EU documents. The script downloads the page ...
4
votes
1answer
59 views

OO shopping cart class + product class interaction

I built a small store site for learning purposes. I loaded my 'products' from the db into a products class. I used a method from this class to display the products in HTML. Of course, the HTML ...
2
votes
0answers
28 views

Facebook crawler redirect to force displaying own opengraph meta-tags

For my website, I use the opengraph to send the right data to the crawler. On the top of all pages on my website, I include the opengraph-script, like this: ...
4
votes
1answer
55 views

Database classes for job offers

I've recently started using PHP OOP, and I'm now working on an application where different company representatives can create job offers that candidates can look at. I have a variety of objects for ...
2
votes
1answer
47 views

Sorting an associative array alphabetically

I am using a foreach loop to sort an associative array alphabetically. I would like to know if there is a more proper and/or efficient way of doing it. The array: ...
2
votes
2answers
35 views

Saving array values for a secondary foreach loop

Although used within the WordPress platform, this is PHP focussed question. I have an array of child posts, some have content, some don't. My client wishes to display the posts in alphabetical order, ...
3
votes
1answer
33 views

Filter, Validate, and Generate Redbean models programmatically

A while ago, I wrote my first Composer Package. The purpose is to completely avoid the tedious work of filtering and validating user input then constructing the model. I have questions about multiple ...
0
votes
1answer
39 views

Numeric and percentage deadband calculation

Calculate if the value exceeds percentage <> numeric deadbands of the previous value. The first function is for percentage. It detects if $value is ...
3
votes
1answer
76 views

One-time secret message application using PHP-encryption library

By utilizing an existing PHP encryption library (defuse/php-encryption) and a flat file database library (jamesmoss/flywheel), my application take a secret message from a user, encrypts it using a key ...
7
votes
1answer
106 views

Class to manage config data to allow DI

I'm writing my own framework (purely for learning purposes, SPL, OOP, patterns, etc) and have written a class to manage config data throughout the framework (not front end/view, just the core ...
1
vote
0answers
82 views

Login authentication model

I have made my model global so that I can work only a model with several controllers. Is it good or bad practice? And according to this, is my login process secure? Login check function in ...
5
votes
2answers
142 views

Restful API Building: Dependency injection + factory patterns

I am learning OOP. I feel I have a grasp of basic dependency injection in that as a rule of thumb, you pass an object to a method rather than the parameters to create an object. As such, never create ...
4
votes
1answer
68 views

Database connection wrapper class

I am trying to create a PHP / MySQLi wrapper class that uses prepared statements, the goal of the class is to create a connection to the Database, then INSERT / ...
4
votes
1answer
187 views

HTML Form validation with PHP

I'm kinda new to PHP and I'm trying to make a script to validate a HTML form only with PHP (I know there are options to do so with JS, but I guess it's better to have a "cover" with a server-side ...
1
vote
2answers
161 views

Lotto/lucky draw

The following script draws 6 numbers at random. I input another 6 numbers and compare with random numbers generated, if they're the same, you win. ...