Organizational Research By

Surprising Reserch Topic

simple php sql login troubleshooting


simple php sql login troubleshooting  using -'php,mysql,sql'

I am trying to create a very basic PHP login by retrieving a registered username/password from a database. This is not ever going live and I am aware there is zero input validation. All I'm trying to do is select data from a database in a login.

Here is the login form on index.html:

    <table width="250" border="0" align="center" cellpadding="0" cellspacing="1"    bgcolor="#CCCCCC">
    <tr>
    <form name="form1" method="post" action="checklogin.php">
    <td>
    <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
    <tr>
    <td colspan="3"><strong>Member Login </strong></td>
    </tr>
    <tr>
    <td width="78">Username</td>
    <td width="6">:</td>
    <td width="294"><input name="Username" type="text" id="Username"></td>
    </tr>
    <tr>
    <td>Password</td>
    <td>:</td>
    <td><input name="Password" type="text" id="Password"></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type="submit" name="Submit" value="Login"></td>
    </tr>
    </table>
    </td>
    </form>
    </tr>
    </table>


And here is the PHP checklogin.php:

   <?php

    $sql_connection = mysqli_connect ("localhost:8889","root","root","derek_website_tmp");

    if (mysqli_connect_errno())
{
 echo "failed to connect" . mysqli_connect_error();
}

    $Username=$_POST['Username'];
    $Password=$_POST['Password'];

    $sql = "SELECT * FROM $Members WHERE Username = '$Username' and Password = '$Password'"
    $result=mysqli_query($sql);

    $count = mysql_num_rows($result);

    if ($count==1) {
    $_SESSION['Username'] = $Username;
    $_SESSION['Password'] = $Password;
    header('location:login_success.php');
    }

    else {
    echo 'Wrong Username or Password';
    }

    if (!mysqli_query($sql_connection))
{
die('Error : ' . mysqli_error($sql_connection));
}

    mysqli_close ($sql_connection);

    ?>


When I try this I get an error retrieving checklogin.php
Any help would be greatly appreciated.
    
asked Oct 13, 2015 by patelnikul321
0 votes
9 views



Related Hot Questions



Government Jobs Opening


...