Jump to content

Help Debugging simple Login page

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
Blue Indian

Blue Indian

    Learning Programmer

  • Members
  • PipPipPip
  • 67 posts
In the following lines of code, for some reason, the php block isn't getting executed when submit is clicked.

Thanks in Advance!

<?php

    session_start();

    if ($_GET['submit'] == 'login'){
        
        if ($_GET['uName'] == 'admin' && $_GET['pWord'] == '1234'){
            $_SESSION['access'] = "yes";
            header('Location:CoffeeSearch.php');
        }
        
        
        else{
            echo "Invalid username and password combination.";
        }
        
    }

?>

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html 
  PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
  <title>DBA Login Page</title>
  
  <style type='text/css'>
      td#col1 {text-align:right;}
    td#col2 {text-align:left; padding-left:10px}
  </style>
</head>
<body>
    
  <form action='login.php' method='get'>

    <table style='text-align:right;'>
        <tr>
            <td id='col1'>Enter username:</td>
            <td id='col2'><input type='text' name='uName' id='uName'/></td>
        </tr>
        <tr>
            <td id='col1'>Password:</td>
            <td id='col2'>
                <input type='password' name='pWord' id ='pWord'/>
            </td>
        </tr>
        <tr>
            <td></td><td><input type='submit' name='submit' value='login'/></td>
        </tr>
    </table>

  </form>
    
</body>
</html>


#2
Blue Indian

Blue Indian

    Learning Programmer

  • Members
  • PipPipPip
  • 67 posts
Ok! Sorry for the double post, but I figured out why the php block wasn't getting executed. It's because I was testing locally and not on the server. Once I put in the correct url, everything worked fine.

:thumbup: