[SOLVED] Login

This is a discussion on "[SOLVED] Login" within the PHP Forum section. This forum, and the thread "[SOLVED] Login are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jan 1st, 2008, 11:32
simonb's Avatar
Blog Moderator

Join Date: Dec 2006
Location: Norwich
Posts: 677
Blog Entries: 4
Thanks: 4
Thanked 2 Times in 2 Posts
Send a message via Skype™ to simonb
[SOLVED] Login

I am creating a simple login and i can't get it to work

/index.php
PHP: Select all

    <form class="search" method="post" action="/login.php">
      <
p>
        <
input name="search_query" type="text" class="textbox" value="Username" />
        <
input class="textbox" type="text" name="search_query" value="*******" />
        <
input class="button" type="submit" name="Submit" value="Login" />
      </
p>
    </
form
And the login.php

PHP: Select all

<?php include('./Connections/Links.php'); ?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  
session_start();
}

$loginFormAction $_SERVER['PHP_SELF'];
if (isset(
$_GET['accesscheck'])) {
  
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset(
$_POST['username'])) {
  
$loginUsername=$_POST['username'];
  
$password=$_POST['password'];
  
$MM_fldUserAuthorization "userrank";
  
$MM_redirectLoginSuccess "/";
  
$MM_redirectLoginFailed "/fail.php";
  
$MM_redirecttoReferrer true;
  
mysql_select_db($database_Links$Links);
      
  
$LoginRS__query=sprintf("SELECT username, userpassword, userrank FROM users WHERE username='%s' AND userpassword='%s'",
  
get_magic_quotes_gpc() ? $loginUsername addslashes($loginUsername), get_magic_quotes_gpc() ? $password addslashes($password)); 
   
  
$LoginRS mysql_query($LoginRS__query$Links) or die(mysql_error());
  
$loginFoundUser mysql_num_rows($LoginRS);
  if (
$loginFoundUser) {
    
    
$loginStrGroup  mysql_result($LoginRS,0,'userrank');
    
    
//declare two session variables and assign them
    
$_SESSION['MM_Username'] = $loginUsername;
    
$_SESSION['MM_UserGroup'] = $loginStrGroup;          

    if (isset(
$_SESSION['PrevUrl']) && true) {
      
$MM_redirectLoginSuccess $_SESSION['PrevUrl'];    
    }
    
header("Location: " $MM_redirectLoginSuccess );
  }
  else {
    
header("Location: "$MM_redirectLoginFailed );
  }
}
?>
It redirects the user to login.php but does nothing
Last Blog Entry: Whats your Niche? (Jun 10th, 2008)
Reply With Quote

  #2 (permalink)  
Old Jan 1st, 2008, 13:36
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: Login

No where in the code do you have the connection to the MYSQL database.
Try this tutorial
http://www.phpeasystep.com/workshopview.php?id=6
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote
  #3 (permalink)  
Old Jan 1st, 2008, 13:42
simonb's Avatar
Blog Moderator

Join Date: Dec 2006
Location: Norwich
Posts: 677
Blog Entries: 4
Thanks: 4
Thanked 2 Times in 2 Posts
Send a message via Skype™ to simonb
Re: Login

On the first line of login.php
PHP: Select all

<?php include('./Connections/Links.php'); ?>

Connections/Links.php

PHP: Select all

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
HTTP="true"
$hostname_Links "localhost";
$database_Links "links";
$username_Links "root";
$password_Links "";
$Links mysql_pconnect($hostname_Links$username_Links$password_Links) or trigger_error(mysql_error(),E_USER_ERROR); 
?>
Last Blog Entry: Whats your Niche? (Jun 10th, 2008)
Reply With Quote
  #4 (permalink)  
Old Jan 1st, 2008, 13:44
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: Login

Ahh ok. Try adding the links.php to the actual file instead of including it.
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote
  #5 (permalink)  
Old Jan 1st, 2008, 13:45
simonb's Avatar
Blog Moderator

Join Date: Dec 2006
Location: Norwich
Posts: 677
Blog Entries: 4
Thanks: 4
Thanked 2 Times in 2 Posts
Send a message via Skype™ to simonb
Re: Login

Ok makes not difference it still goes to that page, and its blank.
Last Blog Entry: Whats your Niche? (Jun 10th, 2008)
Reply With Quote
  #6 (permalink)  
Old Jan 1st, 2008, 14:19
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: Login

Code: Select all
$MM_redirectLoginSuccess = "/";


Surely you need a page there?
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote
  #7 (permalink)  
Old Jan 1st, 2008, 14:21
simonb's Avatar
Blog Moderator

Join Date: Dec 2006
Location: Norwich
Posts: 677
Blog Entries: 4
Thanks: 4
Thanked 2 Times in 2 Posts
Send a message via Skype™ to simonb
Re: Login

No not that tryed it


any i am sure its not that because i think the code is not be actived, On the index page i set the form to go to /login.php is that right?
Last Blog Entry: Whats your Niche? (Jun 10th, 2008)

Last edited by simonb; Jan 1st, 2008 at 14:31.
Reply With Quote
  #8 (permalink)  
Old Jan 1st, 2008, 14:51
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: Login

Try removing the forward slash. Make sure the php does display text when logged in.
Try doing:
1) Set up a login success page
Code: Select all
$MM_redirectLoginSuccess = "loggedin.php"
On loggedin.php put
Code: Select all
<h2>You are logged in</h2>
Check all your links are correct. Try removing the '/' at the front of a link if the file is in the same directory.
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote
  #9 (permalink)  
Old Jan 1st, 2008, 17:17
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: Login

You don't have a POST variable for username
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #10 (permalink)  
Old Jan 1st, 2008, 17:19
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: Login

More clearly:
HTML: Select all
        <input name="search_query" type="text" class="textbox" value="Username" />
        <input class="textbox" type="text" name="search_query" value="*******" />
One should be name="username" and the other name="password".
Nothing is happening in your script as you first check for these variables, but they don't exist so nothing happens.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #11 (permalink)  
Old Jan 1st, 2008, 18:31
simonb's Avatar
Blog Moderator

Join Date: Dec 2006
Location: Norwich
Posts: 677
Blog Entries: 4
Thanks: 4
Thanked 2 Times in 2 Posts
Send a message via Skype™ to simonb
Re: Login

Thanks for that Alex all working

I would give you some Rep

Solved
Last Blog Entry: Whats your Niche? (Jun 10th, 2008)
Reply With Quote
  #12 (permalink)  
Old Jan 1st, 2008, 19:35
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: [SOLVED] Login

Glad you got it working mate.
Small errors like that can be hard to find.
If you think about it logistically though it's easy.
None of your code was being executed and all of it was dependent on that if statement therefore there's obviously something wrong with it
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Need help with HTML login Bravo81 PHP Forum 8 Jan 23rd, 2008 15:20
[SOLVED] php Login page dhossai PHP Forum 26 Oct 17th, 2007 17:53
PHP Login Jack Franklin PHP Forum 25 Oct 10th, 2007 09:27
php login help Aaron1988 PHP Forum 2 Jan 25th, 2007 15:58
Php login cbrams9 PHP Forum 1 Sep 14th, 2006 22:05


All times are GMT. The time now is 20:42.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43