Jump to content

Log-in script help


Go to solution Solved by Ch0cu3r,

Recommended Posts

I'm trying to get my log-in script to work.  I'm getting two undefined variables for $user_loginName and $user_pass.  Plus, even with the correct log and pass I can't log in.  My database connection is good and I didn't misspell the my user table.  Can some see something that I'm unable to see.  Is there an easy way to script this?...if so, got a link?

 

 

Thanks,

CB

<!DOCTYPE html>

<?php 
session_start(); 
$conn = mysqli_connect("localhost","root","","hsa_project_hub");
?>

<!--Project Hub index-->
<html>
	<head>
		<title>Project Hub Login</title>
		
		
		<!-- Modernizr allows HTML5 elements to work in older browsers: http://modernizr.com/ -->
		<script src="js/modernizr.js"></script>
	</head>
<style>

img {
	display: block;
	margin-left: auto;
	margin-right: auto;	
	box-shadow: 5px 5px 5px #888888;
	Float:	left
	position:	relative;
}

#container {
	background: #F0F0F0;
	width: 		300px;	
	display: block;
	margin-left: auto;
	margin-right: auto;
	border-style: solid;
	border-width: 1px;
}

h4	{
	font-family: "Avant Garde",Avantgarde,"Century Gothic",CenturyGothic,AppleGothic,sans-serif;
	font-size: 30px;
	color: #8F0000;
	float: left;
	position: relative;
	left: 70px;
	font-style:italic;
}

#copy_right {
	font-size: 12px;
	text-align: center;	
} 


</style>
	<body>
		
		<div id="container">
			
			<img src="images/hsa-logo.jpg" align="middle" alt=HSA logo>
							
			<h4>Project Hub</h4>	
			
		<!--Start of form-->
		<form action="index.php" method="post"> 			
				
	
		<table align="center" bgcolor="#F0F0F0" width="300" >
			<tr align="center">				
			</tr>
			
			<tr>
				<td align="right"><strong>Log-in:</strong></td>
				<td>
					<input type="text" name="user_loginName" placeholder="Enter your Log-in" required="required"/> 
				</td>
			</tr>
			
			<tr>
				<td align="right"><strong>Password:</strong></td>
				<td>
					<input type="password" name="user_pass" placeholder="Enter your pass"required="required"/> 
				</td>
			</tr>			
			
			<tr align="center">
				<td colspan="6">
					<input type="submit" name="login" value="Login"/>
				</td>
			</tr>
			
			
			
		</table>
	
	</form>
	
	</div><!--End of Container-->
	<p id="copy_right">Heitkamp Swift Architects © 2015</p>
			
			
			<?php
			//Validate log-in and password
				if(isset($_POST['login'])) {
					$user_loginName = mysqli_real_escape_string($conn,$_post['user_loginName']);
					$user_pass = mysqli_real_escape_string($conn,$_post['user_pass']);
					
					$sel = "select * from hsa_users where user_loginName='$user_loginName' AND user_pass='$user_pass'";
					$run = mysqli_query($conn, $sel);
					$check = mysqli_num_rows($run);
					
					if($check==0){						
					echo "<script>alert('Incorrect Log-in or Password.  Try again.')</script>";
					exit();						
					}
					else {
					
					$_SESSION['user_loginName']=$user_loginName;
					
					echo "<script>window.open('main.php','_self')</script>";
											
					}
				}
			
			?>
		
		
		
	</body>
</html>
Edited by CloudBreaker
Link to comment
https://forums.phpfreaks.com/topic/297202-log-in-script-help/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.