473,586 Members | 2,566 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Php Login Page User Authentication Issue

2 New Member
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 $loginFormActio n; ?>

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 2591
Atli
5,058 Recognized Expert Expert
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
dgbergman
2 New Member
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
7652
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 folder. The issue I am experiencing is that when the authentication time out is activated and the user is hence unauthenticated, the browser window...
4
5616
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 SSL no forms auth. One of the subfolders in the public area is the root of a "protected" area; SSL is required from this subfolder on forward and...
4
1969
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> <authorization> <!-- allow tags must be first --> <allow users="Admin"/>
2
2894
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 users). If user is from intranet, web server should recognize it and application should create additional options in controls regarding groups the user...
9
2552
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 header frame and a main frame. When i enter the application, i see the login screen on the whole screen, but when the authentication expires, the login...
7
1950
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 'Web.Security.FormsAuthentication.RedirectFromLoginPage' method thanks, Samuel
3
3192
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 addressed some particular page and was redirected to the login form and would be returned there.). The control's DestinationUrl is only used if the login...
2
2296
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 personnel. When I deploy to my localhost or dev server everything work like it should, Entering a valid user name and password redirectos me to...
0
1154
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 set my custom Remember be cookie on the login page. Following are the details: 1. Authentication mode is ‘Forms’ 2. This issue is reproducible...
0
7912
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8202
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.