Encoding Password

Discussion forum for MOD Writers regarding MOD Development.
Locked
Altutto
Registered User
Posts: 19
Joined: Wed Jul 17, 2013 9:11 am

Encoding Password

Post by Altutto » Sat Aug 24, 2013 1:37 pm

Hello everybody,
I'm a newbie and I tried to adapt this log-in code to my phpbb forum without success:

Code: Select all

<html>
<head>
<title>Login</title>
</head>
<body>
<?php
if(isset($_POST['username']) and isset($_POST['password'])){
$username = $_POST['username'];
$password = $_POST['password'];
}
else{echo 'Please login with your account in order to use this function';}
if((strlen($username)=='0') and (strlen($password)=='0')){echo '    <form id="login" action="login.php" method="post">
        <fieldset id="inputs">
            <input id="username" name="username" type="text" placeholder="Username" autofocus required>
            <input id="password" name="password" type="password" placeholder="Password" required>
        </fieldset>
        <fieldset id="actions">
            <input type="submit" id="submit" value="Enter">
            <a href="../index.html" id="back">Back</a>
        </fieldset>
    </form>';
}
else{ $connect = mysqli_connect('host url', 'username', 'password', 'db'); 

if (!$connect) {
    die('Connect Error (' . mysqli_connect_errno() . ') '
            . mysqli_connect_error());
}
$strSQL = "SELECT * FROM table_users WHERE username = '".$username."' AND user_password = MD5('".$password."')";
function search_escape($strSQL, $char = '\\')
{
    return ereg_replace('[%_]', $char . '\0', $strSQL);
}
		$result = mysqli_query($strSQL);
$row = mysqli_fetch_row($result);
if(strlen($row[0]) == 0){echo 'Wrong credentials.';}
else{$_SESSION['logged'];
echo 'Logged in. <a href="privatepage.php">Click here to continue</a>';
}
}
?>
Please, could anyone help me?

Locked

Return to “[3.0.x] MOD Writers Discussion”