0

below is the index.html which shows the user the password and email entry forms

<!DOCTYPE html>
<html lang="en">
<head>


<title>Ryan Kelly</title>

<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="main.css" rel="stylesheet">

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="js/bootstrap.min.js"></script>


<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-35774778-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async =               true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') +       '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

</head>
<body>
<?php include 'comments.php'; ?>

<div class="container">

<div class="centre">

<div class="well">
    <h1 class="titlecomment">Comment System</h1>

    <h4 class="instructions">Please login below with your username and      password</h4>

    <form class="form-horizontal">
  <div class="control-group">
  <label class="control-label" for="inputEmail">Email</label>
  <div class="controls">
  <input type="text" id="inputEmail" placeholder="Username" method="post">
  </div>
  </div>
  <div class="control-group">
  <label class="control-label" for="inputPassword" >Password</label>
  <div class="controls">
  <input type="password" id="inputPassword" placeholder="Password" method="post">
  </div>
  </div>
  <div class="control-group">
  <div class="controls">

   </div>
  </div>
  </form>

  <div class="greenbutton">
  <button type="submit" class="btn btn-success" method="login()">Login</button>
  </div>

  </div>
  <div class="footer">Created by Ryan Kelly</div>

  </div>

 </div>

and below is the PHP script which checks the email and password and then redirects the user to google, i only redirecting because i wanted to see if it logged in successfully

            <?php        

            function login() {


    $connection = mysql_connect($host, $databaseUsername, $databasePassword);

    $username = $_POST['inputEmail'];
    $password = $_POST['inputPassword'];

    mysql_select_db($connection);

    $queryUsername = "SELECT * FROM login WHERE Username='$username'";
    $queryPassword = "SELECT * FROM login WHERE Password='$password'";

    $searchQuery = mysql_query($queryUsername);
    $searchQueryDatabase = mysql_query($queryPassword);

      if($searchQuery && $searchQueryDatabase = $username && $password) {

        header('Location: http://www.google.co.uk');
      }

}
?>
1

1 Answer 1

1

hre is the problem

if($searchQuery && $searchQueryDatabase = $username && $password) {

you are not fetching the result, and also using assignment (=) when you likely mean comparison (==).

for and example

try $row = mysql_fetch_array($searchQueryDatabase);

now try something like

if($searchQuery && $row['Username'] == $username && $row['Password']==$password) {
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.