[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.


 Subscribe in a reader

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

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Jan 1st, 2008, 11:32
Highly Reputable Member
Join Date: Dec 2006
Location: Norwich
Posts: 721
Blog Entries: 4
Thanks: 6
Thanked 2 Times in 2 Posts
[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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Jan 1st, 2008, 13:36
Jack Franklin's Avatar
Moderator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,405
Blog Entries: 8
Thanks: 18
Thanked 14 Times in 14 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
__________________
Jack Franklin - Webforumz Moderator
(x)HTML | CSS | PHP | MySQL | JQuery (Javascript)
Contact: My Blog | Twitter | Delicious
Want Lessons? PM me.
If you think I've helped, please press the 'Thanks' Button.
Last Blog Entry: A Week with VBulletin (Aug 28th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Jan 1st, 2008, 13:42
Highly Reputable Member
Join Date: Dec 2006
Location: Norwich
Posts: 721
Blog Entries: 4
Thanks: 6
Thanked 2 Times in 2 Posts
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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Jan 1st, 2008, 13:44
Jack Franklin's Avatar
Moderator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,405
Blog Entries: 8
Thanks: 18
Thanked 14 Times in 14 Posts
Re: Login

Ahh ok. Try adding the links.php to the actual file instead of including it.
__________________
Jack Franklin - Webforumz Moderator
(x)HTML | CSS | PHP | MySQL | JQuery (Javascript)
Contact: My Blog | Twitter | Delicious
Want Lessons? PM me.
If you think I've helped, please press the 'Thanks' Button.
Last Blog Entry: A Week with VBulletin (Aug 28th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Jan 1st, 2008, 13:45
Highly Reputable Member
Join Date: Dec 2006
Location: Norwich
Posts: 721
Blog Entries: 4
Thanks: 6
Thanked 2 Times in 2 Posts
Re: Login

Ok makes not difference it still goes to that page, and its blank.
Last Blog Entry: Whats your Niche? (Jun 10th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Jan 1st, 2008, 14:19
Jack Franklin's Avatar
Moderator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,405
Blog Entries: 8
Thanks: 18
Thanked 14 Times in 14 Posts
Re: Login

Code: Select all
$MM_redirectLoginSuccess = "/";


Surely you need a page there?
__________________
Jack Franklin - Webforumz Moderator
(x)HTML | CSS | PHP | MySQL | JQuery (Javascript)
Contact: My Blog | Twitter | Delicious
Want Lessons? PM me.
If you think I've helped, please press the 'Thanks' Button.
Last Blog Entry: A Week with VBulletin (Aug 28th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Jan 1st, 2008, 14:21
Highly Reputable Member
Join Date: Dec 2006
Location: Norwich
Posts: 721
Blog Entries: 4
Thanks: 6
Thanked 2 Times in 2 Posts
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Jan 1st, 2008, 14:51
Jack Franklin's Avatar
Moderator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,405
Blog Entries: 8
Thanks: 18
Thanked 14 Times in 14 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.
__________________
Jack Franklin - Webforumz Moderator
(x)HTML | CSS | PHP | MySQL | JQuery (Javascript)
Contact: My Blog | Twitter | Delicious
Want Lessons? PM me.
If you think I've helped, please press the 'Thanks' Button.
Last Blog Entry: A Week with VBulletin (Aug 28th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old Jan 1st, 2008, 17:17
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: Login

You don't have a POST variable for username
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10  
Old Jan 1st, 2008, 17:19
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #11  
Old Jan 1st, 2008, 18:31
Highly Reputable Member
Join Date: Dec 2006
Location: Norwich
Posts: 721
Blog Entries: 4
Thanks: 6
Thanked 2 Times in 2 Posts
Re: Login

Thanks for that Alex all working

I would give you some Rep

Solved
Last Blog Entry: Whats your Niche? (Jun 10th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #12  
Old Jan 1st, 2008, 19:35
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
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 13:05.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization 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