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

learn more… | top users | synonyms

0
votes
0answers
22 views

Dynamic reports to Laravel view into HTML table

The getDynamicTeacherCount function is generating number-based reports from the table that I have in database and the ...
1
vote
0answers
27 views

PHP rating function for getting the average value of column

I created a function to add and return the average rating. Rating Function ...
3
votes
3answers
59 views

Scrape HTML into separate files for each chapter

I have written a program to read HTML file, find particular text, write text from that particular text to next particular text in a newly opened file. I am interested in code review. I am very new ...
0
votes
1answer
26 views

Laravel bulk insert optimization

I'm currently using a make shift INSERT on DUPLICATE UPDATE function that relies on a DB raw query from eloquent. I'm looking to improve the quality of the code and the speed. Please take a look ...
3
votes
1answer
88 views

Preventing SQL injection without using prepared statements

I'm learning OOP and totally new to this way of coding. I've always scripted PHP the procedurial way. Now I've written a working class, which creates a database connection and has the method to create ...
1
vote
1answer
45 views

PHP Login script getting bypassed allowing access to my admin pages

I have a site where a friendly hacker says they have accessed my admin area. I am not able to see how this is possible so any help would be greatly appreciated. I am using PDO prepared statements to ...
1
vote
2answers
57 views

Mapping a product its corresponding image file

I'm writing this method that elaborates an image name.. I think my logic is not being the best one here but I'm not very savvy in programming yet. Right now it looks like this: ...
-3
votes
0answers
27 views

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean [on hold]

Hey I have gotten the following errors in my code Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in. This error message appears three times on three different ...
-2
votes
2answers
62 views

Assigning variables inside if else with PHP [on hold]

Is this considered good coding practice? I am getting the unique_id from get_unique_id_for_username but if that function ...
6
votes
4answers
882 views

Python, JavaScript, PHP, HTML: Unbeatable Tic Tac Toe

At first, I created an unbeatable Tic-Tac-Toe in Python. However, I wanted a better interface, so I used a PHP backend that runs the script and a simple JavaScript that sends user commands to the ...
1
vote
2answers
57 views

Security concern for SQL Injections/XSS

This question is everywhere, and I looked at many answers. A lot suggest using mysql_real_escape_string but that isn't an option, since it's depreciated now. ...
1
vote
0answers
36 views

API call to a music provider

I have inherited a PHP base class for an API call to a music provider. It is functional, however it makes me feel that there are some "magic" nature behind it that makes me un-easy (or maybe I'm not ...
4
votes
1answer
35 views

Generating statistical reports

I want to generate statistical reports and I have many different where clauses so the function became long. I did much refactoring, but it is not enough. Can ...
3
votes
2answers
74 views

Displaying recent buyers' feedback on games

I have the following code made to output the following: Code: ...
3
votes
1answer
43 views

Simple shop database site

I'm learning PHP, HTML and SQL - and wondered if anyone could take a look at this code and give me some feedback? ...
1
vote
0answers
39 views

Basic vector based drawing OOP design

I had an exercise as below for an interview. I've added my implementation at the end. How could I improve it? Exercise description: Develop a simple vector based drawing package. Your ...
-2
votes
1answer
38 views

Add an HTML body class depending on specific conditions if a block region is present on the web page or not

I wrote this code and I am wondering if there is a better way to phrase this. I was considering switch case but I was not sure how to translate this code into that. The purpose of this code is to ...
5
votes
0answers
60 views

Custom PHP Templating System

I recently decided to see if I could make a functioning templating system. It works, but I feel like it is not all that great. What I'm looking for here is just general critique or ideas to improve. ...
3
votes
2answers
52 views

PHP form validation for name, email, and Twitter handle

Given the following input values from a form, create a method or methods to validate the input based on their requirements. Throw an exception if any data is invalid. 1.1 ...
1
vote
1answer
33 views

Global site settings middleware for Slim Framework 3

I have created this middleware code for slim. I just want to know that is this right way to store site settings globally. so, I can use where ever I want. What do you think about my class structure ...
1
vote
2answers
60 views

Details of a user

Would you please recommend how I could improve this code? My PHP editor only gave a warning about the variable $id. ...
0
votes
1answer
36 views

Acquiring payment service ID

I have a utility class, called Bills, that extracts some information from a billId and a ...
1
vote
2answers
28 views

Assigning browser cookies for A-B testing

The following code creates a cookie on the client browser such that 25% of the browsers will have a value 0, and 75% a value of 1. Can anyone review the following code and point out any problems in ...
2
votes
1answer
24 views

Assigning values from a numerical array to an associative array

I have this function here: ...
0
votes
0answers
20 views

Render HTML/JS with Values for jQuery Modal Boxes

I have some code that I use to render the template + values for the HTML that makes up jQuery Modal Boxes in my code. ...
0
votes
2answers
48 views

PHP alternative syntax confusion

Newbie to PHP. Trying to output the results of an array inside a foreach loop. I have got the following code but I cannot understand what to do with it next. Mainly; Where/how do I start and end ...
1
vote
1answer
36 views

Database query inside a method of a class and return data [closed]

I'm trying to find out what is the right approach to return DB values from a class. This is what I came up with: ...
0
votes
0answers
23 views

Command and observer pattern to build installer wizard

I've done this mainly as an exercise to understand these design patterns. I'm writing a theoretical install wizard which will allow users to select different options throughout, and have it execute ...
0
votes
0answers
21 views

Design Pattern - Abstract Factory Pattern Implementation in PHP

Products Class that are like Table Chair etc Pls review it and give your thoughts and let me know if there are any rooms for improvisation. Products.php ...
1
vote
1answer
47 views

Design Pattern - Strategy Pattern in PHP

Take a look at the following code and let me know if its right, and if there is any room for improvements. Strategy Class ...
-2
votes
0answers
50 views

Beta login api without passwords

In present day, people are asked more & more for new and more difficult passwords all over the web. To be honest, in my case, it is becoming a real struggle to remember all those passwords and I ...
3
votes
1answer
41 views

Autoloader class for PHP

I created a class that I plan on using to autoload my project classes (20-30 classes) maximum. I wonder if there is anything, anything at all, that I can improve on this class to improve it any ...
3
votes
1answer
53 views

MySQL connection using a static connection

I have been using a static class to connect and retrieve information from a MySQL database and also reading about how static works in php. I'm still not sure if the code is bad or not and why (besides ...
2
votes
1answer
35 views

php/html template for checkout

Basically I am in argument with my colleague, I say this template (view) has to be fully refactored and all instances of duplicate code has to be removed. He disagrees and don't want me to touch it. ...
4
votes
2answers
67 views

“Remember me” automatic login

I've implemented a "remember me" automatic login if no session has been set, but a remember me cookie is on their computer. I'm concerned about security and I'm not the best. I'm relatively new to OOP ...
0
votes
1answer
56 views

Proper class user.php

I'm learning to program with PHP, so I ask your help to check if my class user.php is ok. ...
1
vote
2answers
33 views

Correct syntax and improvement account.php file

I wanted to ask your opinion about my code created for acccount.php page for editing the data of each logged-in user. I wanted to have more of an opinion on your right syntax, though maybe it could ...
4
votes
1answer
38 views

PDO connector class

I have created a DB connector class with PDO. Do I need to add, delete or edit anything in this code? ...
2
votes
2answers
56 views

Validating user credentials and logging into a Symfony site

I have the following code in a Symfony site that validates a user's credentials and logs them in via the Session class: ...
1
vote
1answer
47 views

Merging two multidimensional associative arrays

I just wrote a function that will loop through two multidimensional associative arrays and merge them together based on the key names and their values. While I'm satisfied that this function works, I ...
3
votes
2answers
356 views

Web dashboard using many REST API requests

I have created REST API in codeigniter. REST sever created in codeigniter 3.0 and REST client created codeigniter 2.x.x. I have wrote simple code for login. After login client created dashboard ...
5
votes
1answer
48 views

Multilanguage class that detects and sets language

I have been learning object oriented programming for quite a while. I understand many concepts about it but I quickly realized that I made a big mistake just reading theory and not doing any actual ...
0
votes
1answer
29 views

Toggle-able checkbox custom post meta

I have created a basic checkbox custom meta box in order to set a post as "featured". ...
-1
votes
0answers
44 views

Laravel 5 package structure

I'm new with laravel and created my first package, which is a simple cms system. The package is nearly finish and I want to know if I followed the right conventions. What did I wrong (in the code or ...
2
votes
2answers
41 views

PHP Dynamic QueryBuilder function - Security

This function is a working function, which builds a number of queries depending on the values of $_POST. ...
1
vote
1answer
35 views

Class to create dynamic php + mysql queries (safely)

I've started to learn PHP classes, interfaces, extends and things related to those. Before this i've worked only with functions and it started to be quite a mess with hundreads of separate functions. ...
2
votes
1answer
57 views

Creating new team matches

I have a class which creates a new match. My problem is that I am sure the code is unnecessary long and can get much improved (just keep in mind it is beginner level). Specifically, I would like to ...
3
votes
1answer
51 views

Displaying a 0-7 ratings graph

I store ratings in a table called ratings. The table has these columns: id | user_id | value | ip | showcase_id value is ...
3
votes
1answer
54 views

City and District class examples for teaching OOP in PHP

I wrote these two classes for teaching OOP in PHP. Do you think it's breaking some good practices or SOLID principles? ...
3
votes
2answers
56 views

Read a config file into an array

I just wanted to know if this looks like a good way of reading a config file. Is this code good? Is it clean and easy to follow? ...