473,382 Members | 1,353 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Php Login Page User Authentication Issue

I have created a php login page in my site for my company. The goal is to get people into members area. Below is a list of steps that I take to create my login page in Dreamweaver CS3, can some one verify that I have built the page correct and that is nothing wrong with the code. If there is something wrong with the code is it possible to explain a step by step process to have a successful login page as I am new to creting php codes and pages in dreamweaver.

1.create new dynamic php page
2. create form tab
3. insert 2 text fields with a submit button
4. connect to the database on the web server
5.select form
6. add server behavior >user authentication>login user
7.follow the wizard to connect the database to form
8. server behavior created

with an action:<?php echo $loginFormAction; ?>

9. save and upload page to website
10. test page with login
11. page fails and selects the same page started not going to correct links if logged on properly.

Below is the code for my login page. Please tell me if there is a problem with the code or the action.

Expand|Select|Wrap|Line Numbers
  1. <?php require_once('Connections/user.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
  5. {
  6.   $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  7.  
  8.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  9.  
  10.   switch ($theType) {
  11.     case "text":
  12.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  13.       break;    
  14.     case "long":
  15.     case "int":
  16.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  17.       break;
  18.     case "double":
  19.       $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
  20.       break;
  21.     case "date":
  22.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  23.       break;
  24.     case "defined":
  25.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  26.       break;
  27.   }
  28.   return $theValue;
  29. }
  30. }
  31. ?>
  32. <?php
  33. // *** Validate request to login to this site.
  34. if (!isset($_SESSION)) {
  35.   session_start();
  36. }
  37.  
  38. $loginFormAction = $_SERVER['PHP_SELF'];
  39. if (isset($_GET['accesscheck'])) {
  40.   $_SESSION['PrevUrl'] = $_GET['accesscheck'];
  41. }
  42.  
  43. if (isset($_POST['User Name'])) {
  44.   $loginUsername=$_POST['User Name'];
  45.   $password=$_POST['Password'];
  46.   $MM_fldUserAuthorization = "";
  47.   $MM_redirectLoginSuccess = "welcome.php";
  48.   $MM_redirectLoginFailed = "index.php";
  49.   $MM_redirecttoReferrer = false;
  50.   mysql_select_db($database_user, $user);
  51.  
  52.   $LoginRS__query=sprintf("SELECT `User Name`, Password FROM table1 WHERE `User Name`=%s AND Password=%s",
  53.     GetSQLValueString($loginUsername, "-1"), GetSQLValueString($password, "text")); 
  54.  
  55.   $LoginRS = mysql_query($LoginRS__query, $user) or die(mysql_error());
  56.   $loginFoundUser = mysql_num_rows($LoginRS);
  57.   if ($loginFoundUser) {
  58.      $loginStrGroup = "";
  59.  
  60.     //declare two session variables and assign them
  61.     $_SESSION['MM_Username'] = $loginUsername;
  62.     $_SESSION['MM_UserGroup'] = $loginStrGroup;          
  63.  
  64.     if (isset($_SESSION['PrevUrl']) && false) {
  65.       $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];    
  66.     }
  67.     header("Location: " . $MM_redirectLoginSuccess );
  68.   }
  69.   else {
  70.     header("Location: ". $MM_redirectLoginFailed );
  71.   }
  72. }
  73. ?>
  74. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  75. <html xmlns="http://www.w3.org/1999/xhtml">
  76. <head>
  77. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  78. <title>Untitled Document</title>
  79. </head>
  80.  
  81. <body>
  82. <form action="<?php echo $loginFormAction; ?>" method="POST" name="form1" target="_self" id="form1">
  83.   <p>User Name
  84.     <input name="User Name" type="text" id="User Name" size="20" maxlength="20" />
  85. </p>
  86.   <p>Password
  87.     <input name="Password" type="password" id="Password" size="20" maxlength="20" />
  88. </p>
  89.   <p>
  90.     <input type="submit" name="Submit" id="Submit" value="Login" />
  91.   </p>
  92. </form>
  93. </body>
  94. </html>
  95.  
Any help is appreciated!
Aug 31 '07 #1
2 2587
Atli
5,058 Expert 4TB
Hi. Welcome to TSDN!

What exactly is the problem with your code?
Is it not behaving like you expect it to?
Are you receiving any errors?
Aug 31 '07 #2
Hi. Welcome to TSDN!

What exactly is the problem with your code?
Is it not behaving like you expect it to?
Are you receiving any errors?


No, I put everything in correct and when I post my page to the website
I enter the username and password and it just joes to the same page it
was on. Meaning the action for the form isn't authenticating and sending
the correct user id and password to the right page.

Any help would be great!
Aug 31 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Stu | last post by:
Hi All, I have an ASP.NET application to which I have implemented forms authentication to handle security. It is a relatively straight forward solution with all aspx pages residing in the root...
4
by: 23s | last post by:
I had this problem in the past, after a server reformat it went away, and now after another server reformat it's back again - no clue what's doing it. Here's the flow: Website root is public, no...
4
by: SB | last post by:
Hi I'm trying to get forms-based authentication to authenticate different users for differet pages, like this: <configuration> <location path="Member" allowOverride="true"> <system.web>...
2
by: pv | last post by:
Hi everyone, I need help with following scenario, please: Users are accessing same web server from intranet (users previously authenticated in Active Dir) and from extranet (common public...
9
by: dana lees | last post by:
Hello, I am developing a C# asp.net application. I am using the authentication and authorization mechanism, which its timeout is set to 60 minutes. My application consists of 2 frames - a...
7
by: Samuel Shulman | last post by:
Is there a method that will indicate the person who logged successfully is Logged and therefore allowed to browse freely other then using the...
3
by: =?Utf-8?B?TWFyY0c=?= | last post by:
I have a Server.Transfer in my asp:Login LoggedIn event handler. I am forcing transfer to a specific page since I do not want to use the ReturnURL that is in Request.Params (i.e., the user...
2
by: =?Utf-8?B?U2hhbm5vbg==?= | last post by:
I am trying to publish an application to a server that I do not have desktop access to because of our hosting environment. I publish to a file share. The WEB site has been configured by the hosts...
0
by: Anup Daware | last post by:
Hi All, I am facing this very weird issue, for every server request my control is redirecting to the login page and again coming back to the actual page from where the request was initiated when I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.