PHP is a widely-used, general-purpose scripting language that is especially suited for web development.
-1
votes
0answers
7 views
PHP if doesn't work [on hold]
I have wrote a php class for checking captchas into a database
but when I check if it's null into the database, the script returns true even it's false!
here is the piece of code:
...
1
vote
2answers
23 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
10 views
-1
votes
0answers
6 views
How can I add multiple mysql queries in php or wordpress? [on hold]
I'm creating a plugin for wordpress and I want to be able to insert a Gallery title which goes to the the galleryTable and then add Images in the same page that will be added to another imagesTable ...
1
vote
1answer
27 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
46 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
30 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
13 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:
...
1
vote
1answer
25 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
44 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 ...
2
votes
1answer
24 views
Determine value in range, inject to HTML to be used in CSS
I want to show users what package they are, based on how many items they have in their cart. The code works, but I'm wondering if anything can be improved.
...
-2
votes
0answers
19 views
PHP Login System [closed]
I am trying to make login system but i could put nothing in the username and password bar and it still takes me to the users page. I just wanted to know if anything i have here needs to be changed or ...
0
votes
0answers
28 views
Laravel 5 Search
Edited my code and put the "search function" seperately. Still I think I could improve this code a lot, especially this part: if($month !== "") {
And ofcourse ...
0
votes
1answer
27 views
php most elegant function call returning array [closed]
I am asking your preference between two similar solutions.
First way :
...
3
votes
0answers
46 views
Pulling data from API, Allowed memory exhausted
I'm working on a project where I pull data (JSON) from an API. I would like to manipulate this data and store this as useful information in my DB (MySQL). My code is working if I would like to make, ...
1
vote
2answers
29 views
Displaying completed and failed wuuks using one or two functions
I have upgraded my code. In the old code I had two functions: display_maker_success() and display_maker_fail():
...
0
votes
0answers
12 views
Form Builder for RESTFUL API
I have a web app which requires a team leader to be able to add additional text fields of their choice whenever they add a new user.
So for example, by default my app would have the following fields ...
2
votes
2answers
86 views
Throw an exception which contains a nested set of previous exceptions
I have a set of domain objects which try to find a solution to a problem.
The top level object has an algorithm which splits up the problem and delegates it to lower level objects, which in turn do ...
5
votes
1answer
44 views
Mixed scripting language API to determine file upload location and scrape city government website to find corresponding government official
I wrote this script as an NYC-specific-API for file upload for a mobile app. Users upload a video file and also their geographic coordinates.
I then use an external API to get the corresponding ...
1
vote
1answer
22 views
Retrieve and Stores multiple data to database
i am currently working on a project that involves me creating a worksheet for storing student test scores and grades.
i wrote a script that retrieves users information and presents it in form of a ...
2
votes
1answer
77 views
MySQL data fetching without page refresh
I've recently finished a prototype for a little Raspberry Pi website. The main page of the site displays current users found in the room (through bluetooth). I wanted this list updated regularly from ...
2
votes
2answers
63 views
PHP page pagination
I think my code is sloppy can anyone give me advice to do it better?
This is a page pagination that get rows from mysql db and calculate the number of pages.
...
1
vote
0answers
27 views
User model with user roles in Codeigniter PHP/MySQL
I am building an app that currently allows the users to have 3 different roles:
Consumer
Merchant
Admin
I have three tables:
user (Name, email, password etc with a status=0/1)
user_role (The ...
1
vote
0answers
23 views
Uploading LDAP search results to an FTP server
I know this is quite a generic question, I was hoping it could stay open so I can try to improve my styles.
Basically, I have an application that connects to LDAP, performs searches, and produces a ...
0
votes
0answers
16 views
Extended Laravel Eloquent models to add filters to model setters
One of the tasks I find myself doing repeatedly is to filter the incoming inputs that will be stored in models. Examples of this include trimming, removing repeated or unnecessary pre/suffixes, commas ...
1
vote
2answers
65 views
Multiple choice game
This is a multiple choice game. It has a web page where you enter a question, which can have multiple answers along with multiple options.
Can anyone recommend any improvements for my code?
...
5
votes
2answers
60 views
User auth class and security
Just curious if my authentication is secure enough, really. Also wondering if I should ditch the secret variable and just use ...
0
votes
0answers
16 views
Table validator function
I've been working on a function which allows me to validate a table recieved through my REST API:
...
2
votes
3answers
38 views
Manual sorting of database output
I have a small (few elements) list of primary keys, sorted by hand. It come from user input. For example
$ids = [15, 75, 54, 13];
The SQL command is simple.
...
0
votes
3answers
63 views
Which one is the best practice for DRY?
I always prefer to minimize the code, but sometimes I got int conflict with others people by the DRY concept.
In this simple example, which one would be a good choice?
...
0
votes
0answers
21 views
Having critical section for PHP using redis
Currently, I'm using redis to implement critical section for PHP code, to ensure there isn't more than one process/thread to execute the enclosed code block. I was wondering, is there any edge cases ...
5
votes
2answers
54 views
Ranking and storing scores to a database
I am developing a small website with PHP and am trying to receive user exam scores from the database. I rank it based on the highest score and then store the ranking to the database based on the ...
1
vote
0answers
29 views
Basic Container class and KeyParser class
I have written a basic Container class, which is able to hold data by key-value-pairs. The keys can be notated as an array (e. g. ['database', 'host']) or a string, ...
2
votes
1answer
37 views
Storing option value
I currently have a design that is used to store user/selected options in a database, but I am not sure what I am doing is good or not. I need some opinion, suggestion and criticise on the design.
...
1
vote
0answers
31 views
Add user and image upload script
This is my Codeigniter Controller and Model for user image and data upload.
I have some questions here:
Is this good way of writing this script?
Can this code be put to production if its need is ...
5
votes
0answers
28 views
Counting duplicate tags in a string of many tags
I have a photo list page where each photo has multiple tags (as spaced words). I'm trying to display most of the tags on the page after:
Removing duplicate tags
Sorting tags by having most occurring ...
3
votes
2answers
70 views
Simple web form in PHP
This is a simple web form handler in PHP that sends a completely filled web form to a email.
I see lots of repeating code. What is the best way to reduce repetition?
Is my way of checking for fields ...
3
votes
1answer
78 views
Making change using the smallest possible number of coins
I have written code based on the Greedy Algorithm. The example can be found here.
Problem: Make a change of a given amount using the smallest possible number of coins.
Coins available are:
...
2
votes
1answer
40 views
Setting Class Properties
I am adding classes to some legacy code and wondering if there is a more appropriate way to be setting the properties. I am also trying to understand the trade offs, if there is another way to do ...
6
votes
1answer
72 views
Multiple file upload class
I've written this a few days back, which is not too big. Do you see anywhere I can improve my logic?
...
1
vote
1answer
60 views
Laravel API design
I've been designing and coding my Laravel API boilerplate for couple days now, and I'd like to hear some advice/improvement hints!
I'm pretty satisfied with the result, but I'm also aware, there ...
2
votes
1answer
59 views
Secure array encryption and decryption
I have written the below class which encrypts and decrypts a PHP array. The encrypted data and the hash are sent over an insecure connection and I would appreciate if you could check the code for any ...
1
vote
1answer
57 views
Generating tables of numbers in PHP
I have this code and this works fine but I think it's too lengthy. I want to know if there can be a less lengthy code. I've heard from people that lengthy code is often not considered good.
...
2
votes
1answer
45 views
PHP class to represent types of refrigerants
I'm relatively experienced with Java and C++ so picking up PHP wasn't too difficult. I wanted to get some feedback on my first PHP class. There's nothing extremely complicated as of now, but its nice ...
1
vote
0answers
18 views
PHP to Powershell - Transport Function
I had previously made a script for an Active directory password changer but i wanted to compress the main component into a function by itself to keep it small.
...
1
vote
0answers
43 views
URL image validation
I'm trying to write a method to validate an image from a URL. The method will accept an array of image URL. The image should be validated by its type, size and dimensions. Right now, I'm able to ...
5
votes
3answers
101 views
Get similar posts with manyToMany relationship
I have a table post with a many-to-many relationship with the tag and product tables.
...
1
vote
0answers
48 views
JWT with Firebase php-jwt
So my web app requires JWT authentication and I decided to make a mockup wrapper class for php-jwt before implementing it into my web app:
...
1
vote
0answers
195 views
Repository pattern in laravel 5.1
I am currently working on an ecommerce project in Laravel 5.1.
I have implemented Repository Pattern by learning from this site only for 1 model, namely, ...
3
votes
1answer
48 views
Printing a huge document
I have a web page containing n pages of paged data, showing 20 records at a time. The front end has a link to another page that opens the same data, but without the paging and calls ...