urgent advise needed please, username and password

This is a discussion on "urgent advise needed please, username and password" within the Databases section. This forum, and the thread "urgent advise needed please, username and password are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Databases

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jun 6th, 2007, 14:39
Junior Member
Join Date: May 2007
Location: uk
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
urgent advise needed please, username and password

Hi I am new to databases, I am looking to install a member log in script, I have the username and password added to the database and the php files are uploaded to my server, however when the log in box appears and I enter the username and password I set up in the database it says username and password incorrect.

Here is the php code, if someone could advice me of what parts to change, that would be much appreciated.

config1.php
PHP: Select all

<?php
// *************************************************************************************************
// Title:    PHP AGTC-Membership system v1.1a
// Developed by:  Andy Greenhalgh
// Email:   andy@agtc.co.uk
// Website:   agtc.co.uk
// Copyright:  2005(C)Andy Greenhalgh - (AGTC) - Updated 04/06/06
// Licence:   GPL, You may distribute this software under the terms of this General Public License
// *************************************************************************************************
// 
// PLEASE AMEND THE CODE BELOW WITH YOUR DETAILS FOR YOUR SERVERS DATABASE
$localhost "localhost"// YOUR LOCAL HOST, USUALLY localhost
$dbuser "I put my cpanel username here, "// YOUR DATABASE USERNAME
$dbpass "And my cpanel password here"// YOUR DATABASE PASSWORD
$dbtable " I put name of database here";// THE NAME OF YOUR DATABASE , THIS SHOULD HAVE BEEN SET WHEN YOU INSTALLED dbuserdb.sql, SO YOU CAN LEAVE THIS
// PLEASE AMEND THE CODE BELOW WITH YOUR URL & FOLDER DETAILS
$site_url "http://www.lm-lakeland-design.co.uk"// CHANGE THIS TO YOUR OWN WEBSITE URL Ie.(http://www.mysite.com)
$site_folder "index.php"// WHERE YOUR AGTC CLICK COUNTER FOLDER IS (/myfolder/membershipscript/)
$sendersName "My Website Title"// 
// YOU DO NOT NEED TO EDIT BELOW THIS LINE
$con mysql_connect("$localhost","$dbuser","$dbpass")
        or die(
"Error Could not connect");
$db mysql_select_db("$dbtable"$con)
  or die(
"Error Could not select database");
What do I need to change it the log in script below?
PHP: Select all

<?php
// *************************************************************************************************
// Title:   PHP AGTC-Membership system v1.1a
// Developed by: Andy Greenhalgh
// Email:  andy@agtc.co.uk
// Website:  agtc.co.uk
// Copyright: 2005(C)Andy Greenhalgh - (AGTC)
// Licence:  GPL, You may distribute this software under the terms of this General Public License
// *************************************************************************************************
//
session_start();
include(
"config.php");
$msg "";
if (isset(
$_POST['Submit']))
{
 
 
$username $_POST['username'];
 
$password md5($_POST[password]);
 
 
$result mysql_query("Select * From login_table where user_name='$username'",$con);
 
 if(
mysql_num_rows($result)>0)
 {
  
$row mysql_fetch_array($resultMYSQL_BOTH);
  if(
$password == $row["user_pass"])
  {
   
   
$_SESSION['loginok'] = "ok";
   
$_SESSION['username'] = "username";
   
$_SESSION['password'] = "password";
   
$_SESSION['level'] = $row["user_level"];
   
   
   
header("Location: index.php");
  }
  else
  {
   
$msg "Password incorrect!!";
  }
 }
 else
 {
  
$msg "Username incorrect!!";
    }
}
?>
<html>
<head>
<title>Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<p align="center"><strong>PHP AGTC-Membership system v1.1a</strong></p>
<form name="form1" method="post" action="">
  <p align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Please 
    enter your username and password to login</font></p>
  <p align="center"><?php echo "<font color='red'>$msg</font>" ?></p>
  <table class="table" width="35%" border="0" align="center" cellpadding="1" cellspacing="1" bordercolor="#000000">
    <tr bgcolor="#000000"> 
      <td colspan="2"><div align="center"><font color="#FC9801" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>LOGIN</strong></font></div></td>
    </tr>
    <tr> 
      <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Username:&nbsp; </font></div></td>
      <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <input name="username" type="text" id="username" width="200">
        </font></td>
    </tr>
    <tr> 
      <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Password:&nbsp; </font></div></td>
      <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
        <input name="password" type="password" id="password" width="200">
        </font></td>
    </tr>
    <tr> 
      <td><a href="http://www.agtc.co.uk" target="_blank"><font color="#ffffff">http://www.agtc.co.uk</font></a></td>
      <td><div align="center">
        <input type="submit" name="Submit" value="Submit">
      </div></td>
    </tr>
  </table>
<p align="center" class="smallErrorText"><a href="forgot.php">Forgot Password ? </a></p>
</form>
<p align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>
Powered by PHP AGTC-Membership system v1.1a</a></strong><br>
</font> Developed by <strong>AGTC Websolutions @ </strong><a href="http://www.agtc.co.uk" target="_blank">http://www.agtc.co.uk</a></p>
<p>&nbsp; </p>
</body>
</html>
Thanks Loads

Marie

Last edited by karinne; Jun 6th, 2007 at 14:45. Reason: Please use [php]...[/php] tags when displaying PHP code!
Reply With Quote

  #2 (permalink)  
Old Jun 6th, 2007, 14:47
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: urgent advise needed please, username and password

Do you have the login_table created?

Did you put a username and password in there?
Reply With Quote
  #3 (permalink)  
Old Jun 6th, 2007, 15:06
Junior Member
Join Date: May 2007
Location: uk
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Re: urgent advise needed please, username and password

Hi, thank you for your reply
I created the database and assigned a username and password, is that what you mean?
Reply With Quote
  #4 (permalink)  
Old Jun 6th, 2007, 15:09
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: urgent advise needed please, username and password

Not really ... the second chunk of code you pasted refers to a login_table

PHP: Select all

$result mysql_query("Select * From login_table where user_name='$username'",$con); 



so ... you need to create that table in your database (if it's not created already) and put a username and password in that table.
Reply With Quote
  #5 (permalink)  
Old Jun 6th, 2007, 20:36
Junior Member
Join Date: May 2007
Location: uk
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Re: urgent advise needed please, username and password

Hi, I have created a table but I'm not sure how to assign a username and password to it ?

Also I keep getting the error, error could not connect.

I think I may be entering the wrong username and password.

For example purposes

If my username to log into my cpanel was waterbridge
and the password to log into my cpanel was dispenser
and my databases was called learn.

This is how I would have the config.php, is that wrong?

PHP: Select all

<?php
// *************************************************************************************************
// Title:    PHP AGTC-Membership system v1.1a
// Developed by:  Andy Greenhalgh
// Email:   andy@agtc.co.uk
// Website:   agtc.co.uk
// Copyright:  2005(C)Andy Greenhalgh - (AGTC) - Updated 04/06/06
// Licence:   GPL, You may distribute this software under the terms of this General Public License
// *************************************************************************************************
// 
// PLEASE AMEND THE CODE BELOW WITH YOUR DETAILS FOR YOUR SERVERS DATABASE
$localhost "localhost"// YOUR LOCAL HOST, USUALLY localhost
$dbuser "waterbridge_learn"// YOUR DATABASE USERNAME
$dbpass "dispenser"// YOUR DATABASE PASSWORD
$dbtable "learn (but not sure if this needs to be in or not)";// THE NAME OF YOUR DATABASE , THIS SHOULD HAVE BEEN SET WHEN YOU INSTALLED dbuserdb.sql, SO YOU CAN LEAVE THIS
// PLEASE AMEND THE CODE BELOW WITH YOUR URL & FOLDER DETAILS
$site_url "http://www.lm-lakeland-design.co.uk"// CHANGE THIS TO YOUR OWN WEBSITE URL Ie.(http://www.mysite.com)
$site_folder "/myfolder/membershipscript/"// WHERE YOUR AGTC CLICK COUNTER FOLDER IS (/myfolder/membershipscript/)
$sendersName "My Website Title"// 
// YOU DO NOT NEED TO EDIT BELOW THIS LINE
$con mysql_connect("$localhost","$dbuser","$dbpass")
        or die(
"Error Could not connect");
$db mysql_select_db("$dbtable"$con)
  or die(
"Error Could not select database");
?>
Thanks For any Advice

Marie

Last edited by karinne; Jun 7th, 2007 at 01:23. Reason: Reason: Please use [php]...[/php] tags when displaying PHP code!
Reply With Quote
  #6 (permalink)  
Old Jun 7th, 2007, 01:24
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: urgent advise needed please, username and password

That looks ok to me.

Check with your host ... maybe it's not localhost you have to use?! And are you sure your username and password to login in your db is the same as your cpanel?
Reply With Quote
  #7 (permalink)  
Old Jun 7th, 2007, 11:42
Reputable Member
Join Date: Apr 2007
Location: Scotland
Age: 17
Posts: 233
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Blake121
Re: urgent advise needed please, username and password

Looks fine to me. Probably is a problem with you not being on localhost like karinne says.

Just thinking though.... shouldn't $dbtable be the database name instead? because it's using it to connect to the database. I would think it should be

PHP: Select all

$dbname "YOUR DB NAME";
$db mysql_select_db("$dbname")
  or die(
"Error Could not select database"); 
Reply With Quote
  #8 (permalink)  
Old Jun 7th, 2007, 12:51
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: urgent advise needed please, username and password

You appear to be confusing the login name/address for your server host with the login name/address for your database. They are two different animals. (The username and password you need is not for the table, but for the specific database. )

If you haven't done this already, go to cpanel and navigate to the "MySQL databases". That will give you a fairly intuitive GUI where you will:

1) set up a couple of usernames and passwords, maybe name one username "admin" and one "user" or something easy to remember. Write them down on a piece of paper.

2) Then, add the usernames to the database with specified permissions. You want one username (e.g. xxxxx_user) to use for the general public, with extremely limited permissions, and another private one (e.g. xxxxx_admin) if you want add/modify/delete permissions from php.

3) Once you have added the username(s) to the database, the MySQL Databases function will actually give you a pattern path for php!

My strong hunch is that "localhost" is correct, since it seems your database and webpage are on the same server.

Finally, make sure that the path in your PHP connection script is correct. I ALWAYS put the connection script in the root directory -- this is very important. You do not, under any circumstances, want the public to see the "public" username/password.

You have a directory, most frequently named "/public_html/", where you put files you want to access from the internet. This is whatever directory your index.html or index.php page goes into.

Put your database access file higher than this "public_html" or whatever directory. That way, your php scripts will be able to access it, but it can't be accessed from the web.

So on your pages, you would have something like
PHP: Select all

session_start();
include(
"./../config.php"); 

Last edited by masonbarge; Jun 7th, 2007 at 12:59.
Reply With Quote
Reply

Tags
error

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
Urgent Help Needed! dhossai Databases 6 Oct 28th, 2007 02:30
Need help with Username and Password database.!asap tcpodg PHP Forum 8 Sep 26th, 2007 14:12
Very urgent help needed gotmad PHP Forum 2 Sep 19th, 2007 14:45
Username & Password robukni PHP Forum 13 Apr 4th, 2007 22:36
what is default sqlserver username & password ? clickme_not Databases 1 Aug 27th, 2006 17:57


All times are GMT. The time now is 01:30.


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