Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [pdo]

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

4
votes
2answers
91 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
31 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
78 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
91 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
66 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
57 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
147 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. ...
3
votes
2answers
79 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
122 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
134 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
98 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
141 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
261 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
180 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
88 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: ...
2
votes
4answers
511 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
75 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
153 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
70 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 ...
1
vote
1answer
53 views
2
votes
2answers
561 views

Login System using PHP and PDO Prepared Statement

vir.php ...
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
277 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
1k 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
166 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
134 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
65 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 ...
2
votes
2answers
194 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
vote
0answers
236 views

PHP PDO user class

I'm working to implement an users management class inside an already existing project, so I wrote this simple code that will be called from a controller who is responsable to hash the password and ...
1
vote
1answer
55 views

store and warehouse management class

I've already posted this PHP class few days ago when I started writing it. Now that all the methods and all the controller logics are ready, I will be ask here for some suggestions about how to ...
3
votes
2answers
90 views

warehouse management class code

I'm writing a simple class to manage a warehouse, so it's supposed that it will use a database connection. All works fine for now, and I'm actually working to finish the UI. Since I think to be a ...
2
votes
1answer
49 views

Use parameter to filter results in a database without directly allowing users to access database

So background context: I wrote this script for a personal project that holds a large amount of items, I already display and am able to filter the results based on its country/location. I am a student ...
6
votes
1answer
2k views

Role Based Access Control (RBAC) System

I have been working on creating my own implementation of an RBAC system for the purpose of: learning to use an OOP approach instead of procedural switch from using mysqli to PDO and to learn how to ...
3
votes
3answers
271 views

PHP Signup & Login

I want everything to be well and secure with my authentication code. I've done many signup and login systems before but just for testing purposes, and didn't take into consideration all the security ...
0
votes
0answers
102 views

Very simple RESTful API dispatching in PHP

This code is meant to be a very simple RESTful API. The simple router takes the URI request and maps it to a function with a matching name. E.g. www.domain.com/bill maps to function bill(). Then bill ...
1
vote
0answers
42 views

Nightly script to update database

I have a portion of a script here, and the whole script works just fine. However, I feel like it's inefficient and may work better in a class/function format. This is a script scheduled to run every ...
1
vote
1answer
53 views

Insert and update SQL entries for posts to be accessed by up to 3 other users

At first, I have this HTML I use here: body { text-align: center; } ...
5
votes
1answer
911 views

Simple URL shortener

This URL shortener is just for my own use and it runs on my local machine. I created this for fun and I doubt if I would ever use it in production. Is my script any good? shortener.php ...
3
votes
1answer
131 views

PHP RESTful API for a student repository

All of the codes are based on the PSR-2 standard. Also Dependency-Injection and Repository patterns are followed. I would love to hear some advices or comments. StudentRepository Class ...
1
vote
1answer
876 views

PHP PDO Class with multiple Select Efficiency and speed [closed]

I am very new to classes, and not sure how efficient this class is, would appreciate improvement feedback and info on efficiency including speed. The class includes a construct that creates a ...
0
votes
1answer
93 views

Making CRUD abstracted class in PHP

I did a working CRUD abstracted class, and I am not sure that this is a good way for it, so I would like to hear your opinion. ...
2
votes
1answer
92 views

Object-oriented PDO wrapper

So, I've recently started learning OOP in PHP and learned $this keyword. I know it's a reference to the current object. So I wrote a class and couple of functions ...
1
vote
2answers
203 views

PHP PDO statements

I wrote a piece of code. and to be honest it seems a bit messy so I would like some opinions on it, and if I can make it cleaner. Or if there are better ways to do it: ...
-1
votes
1answer
802 views

Mysql flexible insert record with bind_param or bind_value

I want to insert rows in a database table with the precaution of SQL-injection. I'm using below flexible MySQL insert function, which enters a record in a given table. Is this the best approach or is ...
3
votes
1answer
114 views

Finding sessions associated with an IP address using PDO

Originally Posted on Stack Overflow First of all I want to say that I'm new to PDO. I did tried it once but since I found the oop solution complicated and even impossible (...
5
votes
3answers
786 views

Ajax Voting System

Everything works, but my strong suit definitely isn't JavaScript or jQuery. I'm sure there is some way that this can be accomplished that doesn't look so hacky. HTML: ...
1
vote
2answers
735 views

Custom PDO wrapper class

I somewhat recently asked a question on here for advice on a PDO function that I had written. I got some good advice from a user, and went with it. I had used that function for about 3 months which is ...
1
vote
2answers
114 views

Session Control

I am implementing my first app using MVC. I would like to know if the approach I thought for the session system is a good and scalable one. Well, basically a session is stored in my MySQL database ...