Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,389 members, 7,808,376 topics. Date: Thursday, 25 April 2024 at 11:07 AM

Logging In Problem: I'm Using Php And Mysql - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Logging In Problem: I'm Using Php And Mysql (2092 Views)

Android Quiz Application With Json Parser, Php And Mysql Database / How To Make a DESKTOP Executable Software Using PHP,MYSQL,SQLITE / Logging In Problem: I'm Using Php And Mysql (2) (3) (4)

(1) (Reply) (Go Down)

Logging In Problem: I'm Using Php And Mysql by dee02(m): 5:19pm On Feb 03, 2008
Hi,
I'm not a good programmer at all but i was hoping if someone could help me out with this problem.
Basically, when i put in the username and password for a webpage I'm trying to create, it directs to me localhost/webpa/login_check.php and produces this result

?>

I'm using php and mysql but I'm having problems logging in. I have attached the code for my login.php and login_check.php. I would really appreciate it if anyone could help me out. thanks

Re: Logging In Problem: I'm Using Php And Mysql by dee02(m): 5:23pm On Feb 03, 2008
by the way i'm sorry for posting this 3 times.im new on nairaland and i didn't know i had posted it. I'm trying to delete the other 2 posts but i don't know how to delete them,
Re: Logging In Problem: I'm Using Php And Mysql by skima(m): 12:18pm On Feb 04, 2008
do you know how the library works at all? cos i can see you are using a library written by someone (may be u).

the authentication class does the verification as i can see it, if ur username and password doesnt match then you wont be logged it. this as i can see is complex for you (since you claim to be 'not a good programmer'). i will advise u try some simple login so dat you can easily debug wen error comes up like this.
Re: Logging In Problem: I'm Using Php And Mysql by skima(m): 12:22pm On Feb 04, 2008

<?
session_start();
if(isset($_SESSION['user'])){
header("location: index.php"wink;
exit;
}
if(isset($_POST['login'])){
global $err;
include_once "connect.php";

$cc=$db;
$uname=mysql_reak_escape_string($_POST['uname']);
$pwd=md5($_POST['pwd']);
$sql=mysql_query("select * from user where uname='$uname' and pwd='$pwd'"wink;
if(!mysql_num_rows($sql)){
$err="<p class=\"error\"> Your username and password does not match our record.</p>";
}else{
$fet=$mysql_fetch_array($sql);
$user_id=$fet['user_id'];
$_SESSION['user_id']=$user_id;
$_SESSION['secure']=md5($uname.time());
$_SESSION['user']=$uname;
header("location: index.php"wink;
EXIT;
}

}
?>
<? echo $err; ?>
<form name="form1" method="post" action="">
<fieldset><legend><p><b>Login To Your Account </b></p></legend>
<table width="" border="0">
<tr>
<td><p>Username</p> </td>
<td><input name="uname" type="text" id="uname"></td>
</tr>
<tr>
<td><p>Password</p> </td>
<td><input name="pwd" type="password" id="pwd"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input name="login" type="submit" id="login" value=" Login ">
<input type="reset" name="Submit2" value="Reset"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<a href="lost.php">Forgot your password </a></td>
</tr>
</table>
</fieldset>
</form>
<p>&nbsp;</p>
Re: Logging In Problem: I'm Using Php And Mysql by skima(m): 12:28pm On Feb 04, 2008
the first if simply check if the user is logged in else present the login form. so after the logging redirect the person to our secure index page.

let me gv u the db structure

here is it:

CREATE TABLE `user` (
`user_id` int(11) NOT NULL auto_increment,
`uname` varchar(20) NOT NULL,
`pwd` varchar(100) NOT NULL,

PRIMARY KEY (`user_id`)
) ENGINE=MyISAM COMMENT='users login' ;
Re: Logging In Problem: I'm Using Php And Mysql by dee02(m): 7:38pm On Feb 04, 2008
Someone actually wrote that code. I'm trying to install a software called webpa and i got the code from sourceforge.net but its the login in page i'm having problems with. I mean they actually put all the code in there and all i need to do is install. I haven't tampered with the code so i don't know why it isn't working. I have tried contacting the person who produced the code but i havnt gotten a reply since.
To skima, what do you suggest i do or to anyone else who can help me out. Do need me to put any other code here for you to take a look at, thanks
Re: Logging In Problem: I'm Using Php And Mysql by ThePhantom(m): 9:42pm On Feb 06, 2008
Based on what you said, when you log in it takes you to localhost/webpa/login_check.php then it displays "?>". It looks like you have an unterminate line on code, check to see if you are missing a semicolon at the end of the line of codes.

Also, I just wanted to check. Looks like you are running this on your local computer, do you have PHP installed?
Re: Logging In Problem: I'm Using Php And Mysql by my2cents(m): 11:24pm On Feb 06, 2008
To All,

No offense to anyone but this issue is a perfect example as to why it isn't just enough to download/use code. One must understand it as well. Simply copying and pasting code without understanding will probably end up costing you more time and money in the long-run. Another case in point:

Someone from NL YIMd me asking to help figure out why a template he downloaded wasn't working properly in Dreamweaver (DW). When I asked him to open the code in notepad, he balked and said, "I am used to coding in design view (I don't think that qualifies as coding but I digress). If I open the code in notepad, how do I add new images or text? shocked shocked shocked" If all he wanted to do was change text or the path to an image, why even bother using DW? It's a case of not understanding the underlying code. Of course, I insisted he make the changes in notepad and I guess it didn't go well with him cos he never YIMd me back tongue

Look, I am not saying don't get code from elsewhere. After all, even the code we get from books/online tutorials isn't ours. All I am saying is make sure you understand the code, modify it to see how it behaves, then add it to your codebase. It is the best and only way to learn.

As always, my 2 cents.
Re: Logging In Problem: I'm Using Php And Mysql by uspry1(f): 2:39am On Feb 09, 2008
@my2cents

I am so sorry to hear that. That's why I avoid not to help someone who don't know nothing about PHP/MySQL to copy and paste coding into their web hosting in order to run the web page.

@dee02

First, have you installed Apache/PHP/MySQL on your computer (stand alone local host)? Or register your domain name using their web hosting server for accessing FTP username/password to upload your login form/login_check.php at html directory folder (remote host)?

If you must copy and paste  the coding from sourceforge.net to your web hosting server, then you are responsible to modify the new username/password to be matched yours using your web editor (Dreamweaver or notepad or other software) on login form/login.php and to create new database table on MySQL database server yourself using Dreamweaver's Database Connection service at below database structure:

CREATE TABLE `user` (
  `user_id` int(11) NOT NULL auto_increment,
  `uname` varchar(20) NOT NULL,
  `pwd` varchar(100) NOT NULL,
 
  PRIMARY KEY  (`user_id`)
) ENGINE=MyISAM  COMMENT='users login'  ;


Then once you finished modifying the login form and login.php, then you upload them to your web hosting server where you login originally. It is ready to use and you test them to ensure the login page is functionally accepting your username/password.

If you can't do it, then you must hire web designer to modify and upload login form for you.
Re: Logging In Problem: I'm Using Php And Mysql by fasanD1(m): 1:19pm On Feb 09, 2008
sorry dee02, you have ready said you know notting about php and mysql, copying and pasting code without understanding each function on it or where you can modify will probably slow down your work

after login page, you still need more pages e.g registration page, membership page and log out page

so, hire web designer to help you out

for more information mail delongpet23@yahoo.com

(1) (Reply)

. / Increasing Security Risks In Nigerian Banks - Bad For Banks / Web Development Or Data Analystics

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 31
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.