|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
newbie needs a once over
hey guys could any of you give this a once over, and tell me if it might remotely work
also i got some Q's at the end the login: Code:
<?
include"(header.php)";
include"(dbconnect.php)";
?>
<form method=post action="<?echo $PHP_SELF?>">
<table cellpadding=2 cellspacing=0 border=0>
<td>Username:</td><td><input type="text" name="username" size=10></td><tr>
<td>Password:</td><td><input type="password" name="password" size=10></td><tr>
<td> </td><td><input type="submit" name="submit" value="Log In"></td>
</table></form>
<?
if ($submit) {
$result=mysql_query("select * from users where name='$username'",$db) or die ("error");
while ($row=mysql_fetch_array($result)) {
if ($row["password"]==$password) {
printf("Successfully Logged In!<a href=\"main.php?\"'>Click Here</a>");
}
}
}
include"(footer.php)";
?>
dbconnect.php: Code:
$db=mysql_connect("localhost","user","pass") or die ("error");
mysql_select_db("database",$db) or die ("error");
annnnnnddddddd to stay logged in i need something like a cookie, where would i put the cookie? and how to i edit to cookie to include what page they were on so if the press back and click a link it wont work? |
|
#2
|
|||
|
|||
|
just try it and find out.
i think u got include syntax wrong. it should be include("header.php"); if each user is unique u dont need the while loop. if they're not unique then u select them wrong. cause you need to able to identify each user as a unique user. so u could've just done PHP Code:
also if you're using a newer version of php. chances are register_globals is OFF. so the variables you get from the form with method post. should be $_POST['submit'] and not just $submit. same goes for $password should be $_POST['password'] u also got a single quote in <a href=\"main.php\"> dont know why u have it there. you'd need to modify it a bit to work with cookies and over multiple pages. =) but really, if u're a noob like me just try things. u'll get them right, eventually. php isnt the hardest one. after u learn the syntax u'll worry about logic. |
|
#3
|
|||
|
|||
|
thanks,
a little bit revised: Quote:
|
![]() |
| Viewing: Dev Shed Forums > Other > Beginner Programming > newbie needs a once over |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|