Current location: Hot Scripts Forums » Programming Languages » PHP » HELP!!!! Problem with my MySQL connected PHP login form :'(


HELP!!!! Problem with my MySQL connected PHP login form :'(

Reply
  #1 (permalink)  
Old 08-19-11, 04:12 AM
Ross_B_00 Ross_B_00 is offline
New Member
 
Join Date: Aug 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
HELP!!!! Problem with my MySQL connected PHP login form :'(

Im new to PHP and MySQL and am trying to get my head around connecting my PHP login form scripts with my MySQL database form login username and password verification. Im completely stuck with this one have been at it all night and i know its probably something silly.

Can anyone HELP!!!!!!

I keep getting the Undefined login error message from one of my PHP file on line 14 in the first file but im quite sure i have defined it:


HTML Code:
[PHP]
<html>
<body>

<form action="index4.php?login=yes" method="POST">
Username:<input type="text" name="user"><br />
Password:<input type="password" name="pass" ><br/>
<input type="submit" value="SIGN-IN" ><p>
</form>

<?php

$user=$_POST['user'];
$pass=$_POST['pass'];
$login=$_POST['login'];

function denied()
	{
	echo '<h3><span style= "color:red"> Access Denied!!! </span></h3><br><br>';
	}
	
function granted ($user)
	{
	echo '<h3><span style= "color:green"> Access Granted!!! </span></h3>';
	echo 'Welcome, ' . $user; 
	}

if($login=='yes')
	{
	$con= include_once "mysql_connect.php";
	$get = mysql_query("SELECT count(id) FROM login WHERE user='$user' and pass='$pass'");
	$result = mysql_result($get, 0);
	
	if (empty($user) || empty($pass))
		{
		denied();
		die("<br>Please fill out user login fields carefully....<br>");
		}
		
	if ($result!=1) 
		{
		granted($user);
		}
		
	else
		{
		denied ();
		}
	}

?>

</body>
</html>
 [/PHP]

The following script is associated with the above script:

PHP Code:

<?php

$db_host 
"localhost";
$db_username "root";
$db_pass "rhianna";
$db_name "signin";

@
mysql_connect("$db_host""$db_username""$db_pass") or die ("Could not connect to MySQL");
@
mysql_select_db("$db_name") or die ("No $db_name Database ");

?>
Attached Files
File Type: txt index4.txt (986 Bytes, 37 views)
File Type: txt mysql_connect.txt (270 Bytes, 24 views)

Last edited by Ross_B_00; 08-19-11 at 04:28 AM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Space Above Form xavier039 CSS 1 07-13-09 10:52 PM
Retriving form data from table using php and mysql haritha Script Requests 1 06-09-09 07:30 AM
[SOLVED] PHP MYSQL problem ryanatdrewreysolutions PHP 14 07-03-08 09:46 PM
PHP form problem jonnekke PHP 6 10-21-05 03:51 AM
php mysql updating problem kevinb PHP 2 11-06-04 03:15 PM


All times are GMT -5. The time now is 08:48 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.