Questions tagged [pdo]

PDO is a PHP extension that serves as a data access abstraction layer for accessing databases.

Filter by
Sorted by
Tagged with
5
votes
2answers
189 views

Dynamic insert function for PDO (for any case)

I created a dynamic insert function for PDO. It does work, but I want to be sure that it is secure and well coded. ...
2
votes
1answer
40 views

Extract users and privileges from MariaDB and MySQL

This was born out of a need to create database users on a new server to allow views to be created correctly when restoring databases. This is designed to be run from a command line NOT via a web ...
3
votes
1answer
83 views

Add post to favorite in PDO and mysql

After lot of research and couple of questions in https://stackoverflow.com/ i managed to create Favorite System in PDO mysql as ...
2
votes
0answers
105 views

PHP Secure Remember Me for Login using PHP Session and Cookies with referer url

I have followed a mysqli tutorial to create a login with cookies and session with remember me authentication in pdo. in tutorial class had a new db_connection, I ...
4
votes
4answers
169 views

Simple login script with sha256 hashing

I have been using this code for a while. I got it from a tutorial 5 years back. Now I'm wondering if it still is secure, or if it's time to find a new one? Maybe it has never been secure enough. ...
3
votes
1answer
76 views

PHP complete pagination code

I'm working on a site where you can read about different songs, listen to them, rate them etc, same with their singer. I've been thinking about how I could create a simple, yet perfectly working ...
2
votes
1answer
129 views

PDO Is this registration secure and well coded?

i finally have been moved to PDO (from MySQLi) and i m now trying to make simple login and registration page (for training purposes). This code does work! But i want to know if it is secure? Also ...
1
vote
1answer
60 views

Categorize & sub categorize from contents of one row and more execute even more queries in results

I have a table called sales and it has below columns: 'id' 'product_type' 'soldDate' 'text' ...
4
votes
2answers
87 views

Query to plot a histogram of song ratings

I wrote code to plot a rating distribution, which looks like this: The most important function is the stats function: ...
2
votes
2answers
66 views

SQL prepared statement to search songs by various text fields

As we know, using PDO and prepared statements, binding a table or column using bindParam is not possible. So for this, I've figured out to use function parameters ...
5
votes
4answers
86 views

PDO MySQL queries for web application to reserve a vehicle

I normally use MySQLi and this is my first time trying out PDO. I am doing this because this is my first web application that is going to be used by the public, hence I want it to be secure. The code ...
1
vote
1answer
74 views

Connect to database, handling errors

I try to handle or catch possible errors with PHP/MySQL for security reasons and would like to know if I'm doing it right. The first case, connection: I use it as a function and call it always when ...
4
votes
3answers
102 views

User management OOP php class

I found a class that i coded for an old project about a year ago and i haven't really touched php in a while. Now i need to use similar functionality again i thought it would be the perfect time to ...
1
vote
1answer
49 views

Database connection and DataMapper

Following my previous question Database interface and PDO adapter, I wrote a new simple class to connect to Database and run a query returning a PDO statement. ...
2
votes
1answer
115 views

Database interface and PDO adapter

I'm writing my own framework in PHP and I want respect the SOLID principles. I made this interface: ...
3
votes
2answers
87 views

Elegant and secure way to create a dynamic query

I want to create a dynamic query to display: all the invoices if the user has moderator rank only his invoices if the user is a simple member code ...
1
vote
1answer
63 views

Displaying a paginated list of forum topics using PHP PDO [closed]

Can someone tell me if this code is safe? Can be sql-injected or something else hacked? Code get some rows from db and show in pages with pagination... if i can improve let me know and show me how, ...
3
votes
1answer
50 views

Proper use of mysqli->close();

database.config.php ...
2
votes
1answer
100 views

PDO library to handle MySQL queries

This is my library class. This does not have any issues but I want to know if I have any mistakes, or ways to improve performance: variable and call (example of ...
2
votes
1answer
74 views

Passing data to HTML template

How can I pass data from database to my HTML template without putting PHP code in my HTML file. Thanks. This is my controller ...
4
votes
2answers
123 views

Rudimentary registration and login system

I'd love for someone to review my code. It works fairly well, but I'm still getting the hang of PHP and want to make sure I've got an iron-clad system that isn't hilariously vulnerable. I'm also open ...
2
votes
1answer
45 views

PDO / HASH Registration form

I just made my first registration form with password confirmation, hashing with BCRYPT and PDO. As a beginner, looking around on StackExchange, I seem to miss a lot. To keep it simple for myself, I ...
1
vote
1answer
236 views

PDO login script

Just started using PDO for my newest project. I'd like to get input on how this login script looks and if I should alter it in any way. When the user clicks the link to the index.php page, a script ...
3
votes
1answer
441 views

PHP PDO search & pagination

I know that OOP is ubiquitous nowadays. Nonetheless I still write procedural PHP. It now seems to me that I had fallen into a spaghetti code trap, because my code starts to seem meaningless even to me ...
2
votes
2answers
71 views

ORM class for Posts

I'm new to PHP OOP and I'm making some tests. I have 2 classes: database and posts and the two interact with each other. Class Database: ...
0
votes
1answer
467 views

PDO multiple queries with 2 different tables

I joined this 2 tables and dropped the user_id afterwards. I am defining the user_id elsewhere in my code based on my session/cookies and I do not want to return this value as a global. Is there a ...
3
votes
3answers
755 views

Dynamic PHP PDO insert method

This is my attempt at making a class for dynamic PDO queries in PHP. The code works, but I would like the hear what I can improve to make it more secure and readable. ...
2
votes
2answers
112 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. ...
0
votes
1answer
257 views

PDO class wrapper

I'm writing one custom class for PDO connection. I want these advantages: Protect credentials: user, password ... Facilitate maintenance: facing future password changes for example Facilitate ...
3
votes
1answer
59 views

Queries to print out on the screen a list of menus

For common users I have 10 queries and for registered users I have 30 queries like this one below, only to print out on the screen the link for the querystrings, a guy said to me that I should escape ...
3
votes
2answers
662 views

User profile system with PHP and PDO - Conditional links for admin

I recently asked for a code review to my login system. This login system was fully directed to the user. Now I have added some code lines to print out some links related to the admin. Basically I ...
3
votes
1answer
337 views

PHP + PDO - Inserting data on the table with a loop

First of all i made a simple code to insert data on my table, with the information from this code i made a loop to insert data on another table for a notification system. I'm new to PHP and i think ...
2
votes
1answer
341 views

Login system with password reset sent to e-mail using PHP and PDO

I really like to use PDO because it's simple and easy to make a safe query, i prepared all queries and used placeholders, i think it's safe but i'm not sure at all, and I'm thinking if i used ...
3
votes
1answer
560 views

PHP code to insert phone number and IP address into a table if not already present

I am currently coding a PHP script that connects to a database and inserts a phone number and IP address if either item is not present in the table. I believe I have completed it and it is working but ...
2
votes
1answer
624 views

OOP and connecting to multiple databases using PDO

I'm just starting to learn OOP and I've setup a class to handle the database connections and wanted to check if I'm going about this the right way. My website is already using PDO for prepared ...
1
vote
1answer
149 views

Edit database content with a web page

I'm new to PDO, and I want to make sure I made this in the correct way. This way is working, but I have a feeling it's unclean. I have this input: ...
3
votes
4answers
1k views

using $_POST array to prepare PDO statement with variables

I have been developing a little, private Blog Site to make notes/ stories of pen and paper rpg games available for me and my players. This is my first project. As I am new to coding in PHP and MySQL ...
2
votes
1answer
79 views

PHP User management class

Here is my code for a class that is responsible for managing some common users task like registration, login and logout. It implements also a sub class that can be used to check the session of a ...
2
votes
0answers
247 views

PHP Login Checker Stage

I have been working on my script which allows people to sign-up and login to my website. I was wondering if someone could review the code. It works but I can't help but feel it could be optimized. ...
1
vote
1answer
73 views

Auto generate database table

I have written my own little auto-generated table class, and I was wondering if you guys can give me some tips on how to make this code more elegant and secure and maybe compact it so I use only one ...
2
votes
1answer
65 views

Insert data on Data Base using PDO Prepared Statement

...
3
votes
2answers
1k views

Login System using PHP and PDO Prepared Statement

vir.php ...
2
votes
2answers
90 views
2
votes
1answer
57 views

Showing all records on a webpage

I have a connection with my database to show all my records on a webpage, and I'm not sure if this code is safe: ...
-1
votes
1answer
665 views

putting sql-query response directly to foreach-loop?

Is there any reason to not do this? Putting the query directly inside a foreach-statment when the only time the result is going to be used is within that location.. ...
1
vote
1answer
3k views

PDO Dynamic query builder

I'm trying to improve my php oop programming skills. As an exercise I wrote this class that will generate and execute dynamic sql queries. I've also writed a class to call various sanitization filters ...
6
votes
1answer
226 views

Password Hashing and SQL Queries

I am new to web development and am working on a portfolio piece, so I would like to make sure I'm not creating obvious vulnerabilities. I am wondering whether there are any clear flaws in the ...
0
votes
1answer
272 views

PDO insert data through transaction method

I have an import books function to insert more than 5000 rows at once, I did some research and did this one but some other places I saw a different kind of methods to insert without looping and ...
0
votes
1answer
79 views

insert multiple tag

I have 3 tables such as books, tags, book_tags. my objective is to insert books info along with tags (tags can be multiple or single). I have two methods one is insert books info 1st and then add tags ...
3
votes
2answers
299 views

Users management php class

After a little bit of troubleshoots, I've finished this simple users registration and login class. It uses PDO to connect to a mysql database, I've tried also to ...

1
2 3 4 5
7