Click here to Skip to main content
15,889,200 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi There,

I am looking for someone who can help me with this;

I will create an login page but everything I do I can press the submit button without insert username and password

What I have tried:

HTML
<pre><body class="login">
		<form action="index.php" method="post">
			<div id="login-wrapper">
				<div id="login_header">
					<font color="00000"><h3>Dashboard</h3></font>
				</div>
				<div class="login-user">
					<img src="img/user.png" alt="User" />
				</div>
				
				<?php
session_start();

$userinfo = array(
                'user1'=>'password1',
                'user2'=>'password2'
                );

if(isset($_GET['logout'])) {
    $_SESSION['username'] = '';
    header('Location:  ' . $_SERVER['PHP_SELF']);
}

if(isset($_POST['username'])) {
    if($userinfo[$_POST['username']] == $_POST['password']) {
        $_SESSION['username'] = $_POST['username'];
    }else {
        echo "You have not requested a login form!";
    }
}
?>
				<h5>Sign in to access to your Mustang admin control panel.</h5>
				<div id="inputs">
					<div class="form-block">
						<input type="text" name="username" value="">
						
					</div>
					<div class="form-block">
						<input type="password" name="password" value="" />
						^__i class="icon-eye2">
					</div>
					<input type="submit" value="Login" />
				</div>
			</div>
		</form>
	</body>
Posted
Comments
Mohibur Rashid 11-Sep-17 17:46pm    
You need to start session before you send amy text to client
Rob¡nUters 12-Sep-17 5:30am    
So I need to set session_start on the end of the php script?
Mohibur Rashid 12-Sep-17 5:51am    
At the beginning of your script
Rob¡nUters 12-Sep-17 6:46am    
It is on the beginning directly after <?php
Mohibur Rashid 12-Sep-17 18:10pm    
Ofcourse, why do you doubt?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900