473,385 Members | 1,317 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

change from PDO to MSQLI

how do i change this to mysqli?


Expand|Select|Wrap|Line Numbers
  1. <?php 
  2.     require 'connect.php';
  3.  
  4.     session_start();
  5.  
  6.     $username = "";
  7.     $password = "";
  8.  
  9.     if(isset($_POST['username'])){
  10.         $username = $_POST['username'];
  11.     }
  12.     if (isset($_POST['password'])) {
  13.         $password = $_POST['password'];
  14.  
  15.     }
  16.  
  17.     echo $username ." : ".$password;
  18.  
  19.     $q = 'SELECT * FROM users WHERE username=:username AND password=:password';
  20.  
  21.     $query = $dbh->prepare($q);
  22.  
  23.     $query->execute(array(':username' => $username, ':password' => $password));
  24.  
  25.  
  26.     if($query->rowCount() == 0){
  27.         header('Location: ind.php?err=1');
  28.     }else{
  29.  
  30.         $row = $query->fetch(PDO::FETCH_ASSOC);
  31.  
  32.         session_regenerate_id();
  33.         $_SESSION['sess_user_id'] = $row['id'];
  34.         $_SESSION['sess_username'] = $row['username'];
  35.         $_SESSION['sess_userrole'] = $row['role'];
  36.  
  37.         echo $_SESSION['sess_userrole'];
  38.         session_write_close();
  39.  
  40.         if( $_SESSION['sess_userrole'] == "admin"){
  41.             header('Location: adminhome.php');
  42.         }else{
  43.             header('Location: userhome.php');
  44.         }
  45.  
  46.  
  47.     }
  48.  
  49.  
  50. ?>
Sep 11 '15 #1
2 1961
Luuk
1,047 Expert 1GB
Why do you want to do that? (see: this)

I think PDO has more advantages than MySQLi
Sep 12 '15 #2
it is because most of my pages are in MYSQLI except the login. changing all the pages to PDO might take longer
Sep 22 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Sami | last post by:
I keep getting the famous 'Too Many Connection' Error, and don't know how to change my variables, so they persist even if i have to restart mysql service. Platform: Windows 2003 Server My...
4
by: J.C. Flores | last post by:
Hello all, First of all, I must state that I'm new to SQL Server, but have been a long-time software guy for quite some time. Please excuse the potential simplicity of the solution to my...
1
by: Spike | last post by:
Hello! Im going to make a javascript for changing alot of images. But im not sure how to do it., where to start.. Ok, first.. this is the isue. I have 3 images(I call them 1a-3a). when u...
2
by: David Haynes | last post by:
If I do $conn = new msqli(...); do I automatically get persistent connections? If not, how do I get them? Fall back to pconnect()? -david-
0
by: beanweed | last post by:
BACKGROUND ---------- I have an ASP.NET application having two panels. In one panel, an XML document, transformed using xsl, is displayed. In the other panel are some controls that allow a user...
10
by: xixi | last post by:
hi, we are using db2 udb v8.1 on windows, normally i would use control center to change bufferpool size since i know the change will be effect immediately for version 8.1, so i right click...
10
by: Fabrizio | last post by:
(Sorry for the crosspost, but I really don't know which is the right newsgroup!) Hi all, I try to change the password to a user that as to change the password at first logon: try {
11
by: Simon | last post by:
Dear reader, The syntax for the VBA code to change the RowSource of a Master Report is: Me.RowSource = "TableOrQueryName"
1
by: monkey1001 | last post by:
my program is suppose to show my due change and i got it working but my change and coins are wrong how can i improve it thank you..(its supposed to be in java)
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.