All Questions
581
questions
7
votes
3
answers
979
views
A simple PHP login form with PDO
I wrote a simple PHP login form website. It has an initialization script, as well as a form to allow a user to login, plus a link to log the user out after logging in.
...
0
votes
1
answer
74
views
PHP login codes suggestions
Now i have a fully functional PHP codes for login and registeration i was wondering if anyone could offer improvements to the code
The code:
Config.php:
...
1
vote
1
answer
139
views
Follow up to Validation Script in PHP
So I've implemented the suggestions in Original question
And now my code looks like this:
...
1
vote
1
answer
113
views
PHP Validation script
The code below is modified slightly from the code in this previous post.
I believe the code below could be improved and more secured but i don't know how so someone please show me how an improved ...
0
votes
1
answer
212
views
SQL & PHP login method
My code is working however it seems to be using old outdated php version so less secure and I'm still new to programming so I'd be more than thankful if someone shows me how an improved updated and ...
4
votes
3
answers
2k
views
Count unique visitor using IP address and make sure that 24 hours has passed before incrementing the counter
I've created a unique page counter using a PHP script. Pages could be videos, images, publications, etc.
Every time a new user views a page, I record the entry and increment the view counter.
I cannot ...
3
votes
1
answer
198
views
PHP MySQLi Wrapper Class For API
I've never had my code reviewed before, so I am taking this opportunity to see what can be improved with my coding style. I am still somewhat "new" to PHP, in the sense that I'm an old dog ...
1
vote
0
answers
23
views
Use API data to ensure current product prices in database data then sort by price
Because I've waited until now to bother learning the magical JSON functions that modern MYSQL affords, I wonder if my code is optimally written and if there are cautions/limitations to be aware of.
My ...
-2
votes
1
answer
79
views
Preventing PHP SQL injection on login [closed]
I had a login code like this:
...
1
vote
1
answer
333
views
Three way Eloquent relationship definition and saving in Laravel
I'm building a Laravel app (with Vue3 and InertiaJS), and I'm attempting to create relationships between three models:
User
Area
WorkHours
where WorkHours is the ...
1
vote
0
answers
53
views
PHP PDO prepared statement with IN [closed]
Here's my code:
...
4
votes
3
answers
385
views
Queries to get products selected in multiple stores
Project description
I'm making a website listing products. The listing goes as following (See here):
Product name
Shop name
Price in that shop
If the product appears multiple times in the table for ...
4
votes
4
answers
485
views
Functions in PHP to run basic MySQL crud
I wrote a list of functions in PHP that I want to use in my pet project as an autoloaded file for all parts of the app. The purpose of these function is to shorten the code you write for MySQL queries ...
0
votes
2
answers
107
views
Search between dates in a WP Query
In the posts I have a date field and a start and end date range. I need to query if it matches date or if it matches between the dates in the range. This Query works, but how can I optimize?
...
0
votes
2
answers
184
views
Version 2: Display visitor's number on your web page (changed code after getting answer for first version)
Version 2: Display visitor's number on your web page (changed code after getting answer for first version).
The first version is here: Display visitor's number on your web page
The "visitors&...
0
votes
1
answer
261
views
Display visitor's number on your web page
Display visitor's number on your web page.
The "visitors" table has only one column (visitor_count) and only one row. The column's initial value is 0.
I know goto should not be used but then ...
3
votes
1
answer
193
views
Proper PDO connection function
I am reviewing the database class for a live website. I am not sure if the current connect function is the best way to create a pdo object as it appears to create a new connection every time it is ...
2
votes
1
answer
232
views
Optimization of laravel pivot table relationship
I have a pivot table called invite_riskarea which is designed as follows:
This table stores the permissions that have a specific user (through an invite id) to ...
1
vote
2
answers
93
views
Having trouble deleting multiple queries (PHP, MYSQL)
I'm having trouble making WHERE IN query work, I was only able to make it work as a foreach loop.
My payload looks like this:
sku[]: BOOK0002
sku[]: BOOK0003
My ...
1
vote
1
answer
150
views
Is this session manager secure?
I'm looking for best practices for writing secure session managers.
I'm making a table for the authorization token (UUID OR GUIDv4) with autoincrement, user_id, token, status (enum) then update status ...
1
vote
1
answer
138
views
Validate avatar image
I want to know if that code is correct and readable.
In class avatar the method getAvatar() validates the data. It checks if the field is not empty and if the photo extension is correct. If not, an ...
0
votes
4
answers
549
views
table name column name from GET parameter
This is a function that reads a setting data from DB.
...
2
votes
1
answer
281
views
PHP OOP: Configuring MySQL DB & query w/ Twig
I decided to up my PHP game and learn some OOP.
I am re-building my website from procedural to OOP, but since I don't want to use a full framework I fiddle with some components.
As a router I use ...
0
votes
3
answers
866
views
url encoding and storing (JS, PHP, MySQL) [closed]
This question is about how best to encode, send and store information between JavaScript, PHP, and MySQL
I am doing a GET request from HTML/JavaScript to my PHP server, which is then storing the data ...
0
votes
0
answers
56
views
Adding more fields to a Questionnaire in a CRUD system
Background on Project
When a customer orders a machine, I have to do something called a telephone site survey, which involves asking them questions about their site making sure everything is okay ...
0
votes
2
answers
3k
views
PHP search multiple filter inputs
Okay so I built this search page that searches for posts but my current code seems so bloated and inefficient.
My script(search page)
...
7
votes
2
answers
204
views
Connect to MYSQL database in PHP with prepared statements
I have recently learned about using PDO. I created a db class which could handle common actions like create, update, delete and select. Is this method a correct way to connect to the database using ...
4
votes
2
answers
291
views
OOP - Contact Form PHP Backend - Procedural to OOP - Dynamic MySQL Prepared Statement PHP
I just converted procedural code to OOP code. Is there any performance or security issue with this code or what should I consider further?
interface
...
1
vote
1
answer
80
views
PHP function that clones HTML form structure to MySQL database structure
I built a function that should greatly simplify working with long HTML forms, that save data to MySQL using PHP.
My forms usually have several hundred input elements that are added / altered / removed ...
4
votes
2
answers
204
views
Using a transaction to create account records
This is my first time using commit and rollback. I just need to know if this is a proper execution of the functions for this particular situation:
...
2
votes
1
answer
858
views
MySQL database custom session handler using PHP with MySQLi extension
I have made the decision to move the storing of session data to the database.
Any new ideas, suggestions are welcome.
Please also give security suggestions.
Like SQL injection is possible here, etc...
...
5
votes
1
answer
139
views
Storing and confirming user input
I am a beginner, and I'm trying to secure a sign-login system on my website. Is my code good/enough to prevent SQL injection?
THIS IS THE SIGN FILES
This is the index.php that takes user input:
...
2
votes
1
answer
92
views
PHP filesystem on a shared file system
I have a project which we need to migrate from an on-prem solution to the AWS cloud. Currently, the software is running on a single instance. It's working fine but the business want the software to be ...
1
vote
2
answers
261
views
Newsletter subscribers management system in CodeIgniter 3
I am working on a online newspaper/blogging application with CodeIgniter 3.1.8 and Twig.
The application is meant to offer developers and designers the possibility to very easily turn their HTML ...
2
votes
1
answer
39
views
Input text upload to MySQL DB
I am uploading and selecting code from my MySQL DB and I have a feeling some of it could be written in a much shorter way but I don't know how. Can someone tell me if this is clean code or if it's too ...
3
votes
1
answer
51
views
Query WordPress database, returning an array of rows
This is one of my first attempts at querying the WordPress database for data, and some my first PHP code ever, so please bear that in mind when commenting.
It is supposed find data between two dates, ...
5
votes
2
answers
288
views
PHP: Simple SQL query builder
I've been lucky enough to get my first job as a junior PHP developer. I am concerned I'm not good enough. I would like to brush up on my coding skills and get as much constructive criticism as I can.
...
-1
votes
2
answers
136
views
My Script Inserts users into a database and hashes the password, I need to know how to prevent SQL injection with Procedural-Oriented MySQLi [closed]
My script works but I just want to know how I can protect myself from SQL injection with Procedural Oriented MySQLi. Most of the tutorials are about Object-Oriented MySQLi and I'm not familiar with it ...
2
votes
0
answers
108
views
Creating calendar - Speeding up PHP script
I'm working on a calendar for my office. Every people has his own column and there is a line for every day.
There are some periodic date, where, for example, given people have to be working on the ...
4
votes
2
answers
444
views
API for SQL queries with PHP PDO
I'm writing a very simple CRUD application, and I'm wondering if the way I'm using static methods throughout the code makes sense. I'd very much like to simplify ...
5
votes
1
answer
455
views
function for PDO queries and return result - tested - any tips?
I write a function using PHP and MySQL, to get PDO connection, query and array of placeholders to execute query and return result.
I test this function and it has good response when result for ...
1
vote
2
answers
125
views
Repeated DB connection at max user connections
I am trying to create class with connect to mysql database. And if there is max number of connections I want to wait and try it again. I figured out, how it can works, but I am not sure, if its the ...
3
votes
1
answer
838
views
Make Pagination using Ajax with Jquery, PHP, History.pushState()
Finally after a few months of searching and learning AJAX with pagination PHP and History.pushState() I created AJAX PHP pagination.
Test page
1. Ajax(index.php)
...
2
votes
1
answer
124
views
Is execution of sql in my php code safe?
So I have two PHP files that execute SQL code in them. It's a simple registration script and an account recover script.
I want to know is my code safe from SQL exploits & other exploits? Here's ...
4
votes
1
answer
597
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 ...
3
votes
2
answers
127
views
Wordpress Ajax Custom Query - High CPU LOAD
I'm developing a fully AJAX community WP theme that comes with a lot of custom queries.
Everything is fine, there is no bug but recently but I had a few clients that have a huge database and my theme ...
5
votes
2
answers
623
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
2
answers
529
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. ..
...
3
votes
1
answer
81
views
Secure upload script
I am creating a social network that let's users upload a profile picture. I just want to know if this is a secure way of doing it. Thanks.
...
8
votes
3
answers
1k
views
How secure is my PHP registration script?
I coded a registration form and was wondering if anyone could give me feedback on whether I'm lacking any major security mechanisms. I've done loads of reading around the topic and feel it should be ...