Questions tagged [php]

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

Filter by
Sorted by
Tagged with
-2
votes
0answers
13 views

How to make signup form complete and connect it to mail [closed]

So I watched this video, where they created a signup-form: https://www.youtube.com/watch?v=GAOBXGPuKqo Now, I have done everything in that video. And the signup-form is ready and looks great. But how ...
8
votes
1answer
9k views

Simple Router class

I made a simple routing class that I like to get reviews for, mostly because I do not know how to make it SOLID, since I even made this class separate from the HTTP response/request for the sake of ...
2
votes
0answers
30 views

OOP: The correct use of classes and optimizing code

I am trying to improved my coding skills. I mainly work in web development. I had a "system" that I use in all my projects to fetch data from my DB to the browser. I tried an implementation ...
5
votes
1answer
65 views

Wordpress single post content class customization with if-else function

I have the following code, which displays the content for my custom page template "landingpage.php" and for single posts. The site is based on Bootstrap 4. ...
2
votes
2answers
111 views

Secure file upload for PDF only

I am trying to create a secure file upload using PHP 7+ where I only allow PDF files. I found a lot of posts on this topic on different websites but couldn't find a complete solution that ensures that ...
2
votes
0answers
16 views

Correct way of doing transactional queries

I am trying to do multiple queries in one call, so I organized my code as below: ...
4
votes
3answers
182 views

PHP comment system

Basics I created a simple comment-system. My goal was it to create a system that can easily be used on everyone's server without having to install a load of programs. I also tried to create it as ...
4
votes
1answer
31 views

Create a CSV from SQL Data and email as attachment using PHP

I put together some functions that allows a PHP script to send the SQL data obtained from user inputs on a website via an email attachment as a CSV file. It works perfectly and I have no issues with ...
1
vote
1answer
154 views

Laravel show and update currency from rest api

I need: Daily save new exchange rates from the REST API in the database. Return the current exchange rate for a given currency, the whole table for a given day, the exchange rate for a given currency ...
5
votes
1answer
84 views

Whitelist for textarea and save input to file

I'm working with product codes, so a user can only scan these type of product codes into a textarea element. I don't know if my code is written the best way possible, or has good performance. I'm ...
8
votes
2answers
321 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 ...
2
votes
0answers
27 views

I need a better way to add css per each page on wordpress

I just started to use Wordpress to start building a website, but as I need to use the get_header() function to retrieve the ...
3
votes
1answer
60 views

Filtering multiple request parameters

This is pretty straightforward, it takes requests from the frontend, checking if it is present on the request, if it does, an action is taken for that if statement. I wonder if there is a way to ...
3
votes
0answers
23 views

Add pivot data from the same pivot model

My project has thee models Cart, Order and Product Cart ...
0
votes
1answer
64 views

Learning factory design pattern [closed]

I'm making the very common example of Factory design pattern which creates a factory of cars and return an instance of a car. I found a example here https://refactoring.guru/design-patterns/factory-...
0
votes
0answers
34 views

Wordpress Ajax Custom Query - High CPU LOAD

I'm developing a fully ajax community WP theme that comes with alot of custom quaries. Everything is fine, there is no bug but recently but I had a few client that have a huge database and my theme ...
5
votes
2answers
136 views

Queries to get unpaid and unpaid invoices

Here is my code: ...
2
votes
1answer
73 views

Should I separate the classes in types and increase decoupling?

My goal is to make a form builder class, that generates bootstrap 4 form inside a modal. My doubt is whether I should leave it as is or if I should crate a interface and then implement that interface ...
2
votes
1answer
148 views

Prefixing prices of certain product categories with text in Woocommerce

I had the need to prefix the price for certain product categories on only the shop page (because the price can be higher depending on extras that the customer might want). These were my requirements ...
3
votes
3answers
133 views

Email Validation in PHP

Is this script sufficient enough to validate user email input? ...
3
votes
1answer
153 views

Sanitizing user form input in php

Security threats in mind: SQL Injections!!! --- Solutions: Prepared Statements (PDO) and including $bpdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); in ...
3
votes
0answers
51 views

Mysql PDO Wrapper that throws Unique Constraint Exception

The main reasoning behind this PDO wrapper, is that I find myself using unique constraints quite frequently in my designs, and I have ...
4
votes
2answers
72 views

PHP Email List Sign Up

See my original post: here. I have one html page and four php files that allow users to sign up for an email list. One of the php scripts is a cronjob that deletes unverified rows older than 24 hours, ...
2
votes
1answer
35 views

Route Improvement in Laravel 8

I have below route. I am using Laravel 8. ...
6
votes
1answer
81 views

binary data shell echo generator

edit: here is a cleaned-up version incorporating most (but not all) feedback, thanks guys; https://gist.github.com/divinity76/79efd7b8c0d7849b956cd194659c98e5 I need to... generate a linux shell ...
0
votes
1answer
40 views
2
votes
1answer
45 views

I want to most efficiently use array values and variables in a WordPress template while abiding by PHP/WordPress best practices and standards

Is it better to validate and put an array value into a variable at the top of a file or to check the array value directly right before output in the file? I work at a WordPress shop and we have a ...
4
votes
1answer
2k views
2
votes
1answer
31 views

Modify parameter data before creating an instance of a class in PHP

I have an abstract Badge class, every class extending this class should always correctly set the incoming name (string) and achievedAt (date) fields. There might be other classes that extend the Badge ...
4
votes
1answer
66 views

Social network login and registration forms

I am building a social network with PHP, HTML and CSS and a bit of JS. I want to know how secure my login and register code is. Register html: ...
1
vote
1answer
48 views

Improvements on Laravel's base Model and FormRequest

Introduction I've improved, IMO, Laravel's base Model and FormRequest. It's working as expected. But, before actually implementing this any further in my application, i want to have my classes checked ...
-4
votes
2answers
69 views

Is this a good approach to replace mysqli_num_rows? [closed]

Is this a good approach to replace mysqli_num_rows? $db is a PDO instance. .. ...
4
votes
1answer
189 views

OO and non-OO usage of Mysqli

I'm starting to learn the object oriented aspect of PHP. In this regard I made a small "exercise" of sorts "translating" one of my PHP functions into OO mode of PHP. I'm asking if there are there any ...
3
votes
2answers
173 views

Contact form with spam-prevention - follow-up

Background The basics of this project are already covered here. I received the suggestions to: not create the exercise with JavaScript. use pictures instead of plaintext. I tried to implement the ...
2
votes
1answer
37 views

Get all routes that start with rt_

The code reads all my routes and return to my JQUERY AJAX the names of the routes without duplicates and just those that have "rt_" prefix. ...
3
votes
1answer
70 views

Securely upload multiple image files with PHP

I am working on script to a upload image files Securely. can anyone please review my code and suggest improvements on security. ...
6
votes
2answers
108 views

PHP Mandelbrot Set Generator

I need to get familiar with web programming, so I decided to write up a fairly simple PHP page that accepts GET requests and serves back an image of the Mandelbrot set... as a table of colored cells. ...
0
votes
2answers
3k views

PHP/MySQL to delete data from 4 different tables at once

I have four mysql tables setup like the following: ...
2
votes
1answer
53 views

Secure way of uploading php images and GIF

I am creating a social network and I want to know if this is a secure way of uploading pics/gifs and videos. ...
3
votes
1answer
74 views

Model tournaments between teams

In one of my projects I wrote a little tournament platform, but the way I handle participants is a bit messy and I want to clean this up. So in my case a Tournament can have participants, but either ...
3
votes
2answers
129 views

Sanitize vars on form submit

I have this code and I would like to know if I filtered my code correctly. I am practicing my security coding for a system that I am working on and I would like to know if I am doing it the right way. ...
3
votes
1answer
419 views

Very simple encryption API

I need an encryption system with a super simple API. I'd prefer something as simple as the following. The output should also be browser-friendly and ideally url-friendly. ...
3
votes
1answer
349 views

Enhancing PHP realpath($path);

PHP realpath($path); is insufficient for some cases since it returns false on paths that dont exist on a file system. I need a function that extends realpath($path); to return even path that does not ...
1
vote
1answer
45 views

Class dedicated to transforming API response to the data I need?

I have the following code (in php) that calls the open weather api with my credentials, and returns data for me. Know I'm returning some data I pick from that response, I'm wondering if it's good ...
1
vote
2answers
63 views

Dynamic Accordion in WordPress

I used the Bootstrap v4.0.0 accordion to display my business services. Further, I created a custom post type "service" for my services (Each service is a post). To display my services ...
1
vote
1answer
47 views

Importing data from spreadsheet

Not really an issue I am stuck on (the code works) but I just really don't like some code I wrote, if you're bored in lockdown maybe you might like to help. Context: I am import some data from a ...
5
votes
1answer
26k views

PHP Register Form - OOP

I'm trying to build my first object oriented system. I'm not sure that my register function below is the best way of approaching this within OOP. ...
1
vote
0answers
32 views

PHP Laravel Order generation Custom Class Refactor

Here is a custom class code I use to handle different types of orders in Laravel. This question includes the code regarding Order Type A. I want to know whether I can simplify the code more. I have ...
2
votes
0answers
45 views

A UserService method that calls the UserRepository a few times

I'm trying to implement some domain driven design architecture, such as a repository to talk to the database, and a service that talks to the repository. I have an action where I want to see if a User ...

1
2 3 4 5
83