Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 3rd, 2005, 5:02 PM   #11
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Look, Brent. You say your code doesn't work, but you don't show it. Someone suggests you show it, and you do, but you don't point out the areas that don't meet your expectations, or the errors you're getting, or anything. You need to help people help you by providing all the information available. Information is what debugging is all about. As it is, we have to examine your code from top to bottom instead of concentrating on one particular section. Of course, we'll do that, but give us a break, huh?
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Aug 3rd, 2005, 5:37 PM   #12
Brent
Highly Adaptive Penguin
 
Brent's Avatar
 
Join Date: May 2005
Location: United States
Posts: 251
Rep Power: 4 Brent is on a distinguished road
ok here...when i click login, it does nothing, doesnt show any error message, it does NOTHING.
Brent is offline   Reply With Quote
Old Aug 3rd, 2005, 8:55 PM   #13
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Right off the top of my head, before I look in detail, I see your function name is invalid.

EDIT: Oops, your form action in incorrect, also. The action specifies what server page to request (normally a script), it doesn't specify a function name. Let me ask a question: are you aware of the client/server nature of the interaction and exactly what that means in terms of what code is run where?

EDIT 2: You're overlapping your form and table elements in non-compliant ways.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Aug 4th, 2005, 9:19 AM   #14
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
This is how i would do it.

[PHP]
<html>
<head>
<title>Login:</title>
</head>
<body>
<?PHP
switch ($_POST['action'])
{
case "Login":
$username=$_POST['username'];
$password=$_POST['password'];
if($username=='webmaster' && $password=='pass')
{
print("success");
}
else
{
print("failure");
}
break;
default:
?>
<form method="post" name="form1" action="mypage_name.php?action=Login">
<table name="login_menu" width="100" background="pic_1.jpg">
<th>
User info
</th>
<tr>
<td>
Username:
<br>
<input type="text" name="username" size="10">
</td>
</tr>
<tr>
<td>
Password:
<br>
<input type="password" name="password" size="10">
</td>
</tr>
<tr>
<td>
<input type="submit" value="Login">
</td>
</tr>
<tr>
<td>
<b>(</b><a href="register.html">register</a><b>)</b>
</td>
</tr>
</table>
</form>
<?PHP
break;
} //end of switch.
?>
</body>
</html>
[/PHP]

Please note that you should replace "mypage_name.php" with the name of your page. I am sure that you could use phpself() if you really wanted, but you must have the "?action=Login" part for it to work.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!

Last edited by Pizentios; Aug 4th, 2005 at 10:25 AM.
Pizentios is offline   Reply With Quote
Old Aug 5th, 2005, 10:03 PM   #15
Lich
Professional Programmer
 
Lich's Avatar
 
Join Date: May 2005
Location: Detroit
Posts: 254
Rep Power: 4 Lich is on a distinguished road
Send a message via AIM to Lich Send a message via MSN to Lich
If it's 1 user, just use http auth.

[PHP]<?
if (!isset($PHP_AUTH_USER))
{
header("WWW-Authenticate: Basic realm=\"Protected Page\"");
Header("HTTP/1.0 401 Unauthorized");
exit;
}

else if(($PHP_AUTH_USER=="user") && ($PHP_AUTH_PW=="password"))
{
echo "You got in...";
//place page content or re-direct ehre
}

//part 3
else
{
echo "Sory dude, wrong password";
//it didn't work
}
?>[/PHP]

taken from spoono.com, but I've use modified versions before.
Lich is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:32 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC