PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
It is currently Thu Oct 01, 2020 3:45 am

All times are UTC - 5 hours

Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Fri Oct 06, 2017 7:24 pm 
Forum Contributor

Joined: Wed Jan 18, 2017 4:43 pm
Posts: 197

I really need the following code converted to mysqli procedural from pdo oop. Once that is done, my 7 months project will come to an end. And, I can move-on to learning pdo. Right now, can't afford to jump into pdo without finishing my current project.
So, who will help me convert ? Other newbies would learn from your conversion.


Syntax: [ Download ] [ Hide ]

ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
include 'config.php';
// check if user is already logged in
if (is_logged() === true)
        //Redirect user to homepage page after 5 seconds.
        exit; //

if (
        array_key_exists('login_username_or_email', $_POST) &&
        array_key_exists('login_password' , $_POST)
) {
        $usernameoremail = trim($_POST["login_username_or_email"]); //
        $password = $_POST["login_password"];

        // don't bother trimming, they can't enter it right, don't let them log in!

        $stmt = $conn->prepare('
                SELECT ids, usernames, passwords, emails, accounts_activations_statuses
                FROM users
                WHERE '
. (
                        strpos($usernameoremail, '@') === false) ? 'usernames' : 'emails'
                ) . ' = ?
        $stmt->bind_param('s', $_POST['login_username_or_email']);
                $db_id, $db_username, $db_password, $db_email,
        if (
                $stmt->fetch() &&
                password_verify($_POST['login_password'], $db_password)
        ) {
                echo '
                        <p>Login Successful</p>
                                <dt>User Id</dt>
, $db_id, '</dd>
, $db_email, '</dd>
, $db_username, '</dd>
                                <dt>Activation Stats</dt>
, $db_account_activation_status, '</dd>
        } else echo '<p>Invalid username or password</p>';
} else echo '<p>Missing username or password</p>';

<!DOCTYPE html>
<title><?php $site_name?> Member Login Page</title>
  <meta charset="utf-8">
<div class = "container">
<form method="post" action="">
        <h3><?= $site_name ?> Member Login Form</h3>
                <label for="login_name">Username/Email:</label>
                <input type="text" name="login_username_or_email" id="login_name">
                <label for="login_pass">Password:</label>
                <input type="password" name="login_password" id="login_pass">
        <div class="submitsAndHiddens">
                <button type="submit">Login</button><br>
                <a href="login_password_reset.php">Forgot your Password?</a><br>
                <a href="register.php">Register New Account</a>

PostPosted: Sat Oct 07, 2017 3:49 am 
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6425
Location: Montreal, Canada


PostPosted: Wed Oct 11, 2017 12:57 pm 
DevNet Master
User avatar

Joined: Wed Jun 27, 2007 9:44 am
Posts: 4313
Location: Sofia, Bulgaria

There are 10 types of people in this world, those who understand binary and those who don't

PostPosted: Wed Oct 11, 2017 3:45 pm 
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13592
Location: New York, NY, US


Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours

Who is online

Users browsing this forum: No registered users and 47 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group