Hi,
trying to create a simple login page using php and a post form.
The following requirement holds,
1. there should NOT be any DB.
2. One user and one password is enough (yeah, said it was a simple
one...)
Tried with a function check_user() in a lib php-file, and a post form
in the login page. Code as follow:
<?php
function check_user(){
global $userfield, $pwdfield;
if( strcmp($_POST[$userfield],"user") == 0 ) {
if( strcmp($_POST[$pwdfield],"pwd") == 0 ) {
// Correct user
echo("correctdir/album.htm");
}
else {
// Wrong pwd
echo("../somdir/default.htm");
}
else {
// wrong user
echo("../otherdir/default.htm");
}
}
}
?>
and the login page for is:
<?PHP
require('../somelib/login_lib.php');
?>
....
<form name="form1" method="post" action="<?php check_user();?>">
<input type="text" name="userfield" >
<input type="password" name="pwdfield" >
<input type="submit" name="Log in" value="Log in">
</form>
....
Can't get it to work. Any good idea to resolve this? Any other more
brilliant solution instead of this?
br,
Magnus 3 2310
tlakso wrote: The following requirement holds, 1. there should NOT be any DB. 2. One user and one password is enough (yeah, said it was a simple one...)
Can't get it to work. Any good idea to resolve this? Any other more brilliant solution instead of this?
You could do this:
if (!isset($_SESSION["pasword"])){
// generate a password, store it to above place and mail it to yourself
} else {
// output form/validate form when submited
}
--
Dado
The original point and click interface was a Smith & Wesson tl****@hotmail.com (tlakso) wrote in message news:<85**************************@posting.google. com>... Hi,
trying to create a simple login page using php and a post form.
Certainly you have to learn PHP. Buy some good books or Google
for PHP articles.... I'll try to pointout your mistakes... The following requirement holds, 1. there should NOT be any DB. 2. One user and one password is enough (yeah, said it was a simple one...)
Tried with a function check_user() in a lib php-file, and a post form in the login page. Code as follow:
<?php
function check_user(){ global $userfield, $pwdfield;
for what???
if( strcmp($_POST[$userfield],"user") == 0 ) {
Try $_POST['userfield'] if( strcmp($_POST[$pwdfield],"pwd") == 0 ) { // Correct user echo("correctdir/album.htm"); } else { // Wrong pwd echo("../somdir/default.htm"); } else { // wrong user echo("../otherdir/default.htm"); } }
} ?>
and the login page for is: <?PHP require('../somelib/login_lib.php'); ?>
... <form name="form1" method="post" action="<?php check_user();?>">
^^^^^^^^^^^^^^^^^^^^^
<input type="text" name="userfield" > <input type="password" name="pwdfield" > <input type="submit" name="Log in" value="Log in"> </form>
...
Can't get it to work. Any good idea to resolve this? Any other more brilliant solution instead of this?
Basci debugging trick: Run your PHP code on a webserver and
"view source" of the html page to verify.
HTH,
R. Rajesh Jeba Anbiah
---
Email: rrjanbiah-at-Y!com tl****@hotmail.com (tlakso) wrote in message news:<85**************************@posting.google. com>... Tried this with $_POST['userfield'] in strcmp, but still get this: " You don't have permission to access /<br /><b>Notice</b>: Undefined index: userfield in <b>f:\apache\lib\login_lib.php</b> on line <b>11</b><br /> on this server. "
so, the userfield index is undefined. PHP version is 4.3.2 and apache 1.3. Any clue?
It's because, you're trying to get the values before POST. <form name="form1" method="post" action="<?php check_user();?>">
^^^^^^^^^^^^^^^^^^^^^
What do you mean? Is it not possible to call this function there?
You can call a function, but not like JS. Obviously you have to
learn PHP.... If you know HTML, "view html source" of your PHP code.
---
Email: rrjanbiah-at-Y!com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Michael Brennan-White |
last post by:
If I submit my for using a get action the resulting page loads . If I
use a post action I get an error page saying "The page cannot be
found". I am calling the originating page!!! This happens...
|
by: Nathan |
last post by:
Hi,
I seem to having a peculiar problem with the display of odd and even
pages in XSL-FO. Here is a small background of the problem.
My xsl stylesheet mentions my fo:layout-master-set as
...
|
by: James |
last post by:
I've been to websites where if I navigate off a form, trying to get back to
it by hitting the back button gives me a page which says "Warning, page has
expired". It doesn't display the page. I've...
|
by: Kevin Phifer |
last post by:
Ok, before anyone freaks out, I have a solution I need to
create that gathers content from maybe different places.
Each one can return a <form> in the html, so its the
classic can't have more than...
|
by: John Lau |
last post by:
Hi,
Is there documentation that talks about the page lifecycle, the lifecycle of
controls on the page, and the rendering of inline code, in a single
document?
Thanks,
John
|
by: MooreSmnith |
last post by:
When I navigate to the next page using
Response.Rediect("MyNextPage.aspx") current page Page_Load event is called.
What I may wrongly understood is that post back will happen whenever there
is any...
|
by: Lenard Gunda |
last post by:
Hi!
I have the following problem.
From my main page, when someone clicks a button, it uses client side
javascript to open another .aspx page. This page displays content, based on
what the...
|
by: Nathan |
last post by:
I have an aspx page with a data grid, some textboxes, and an update button.
This page also has one html input element with type=file (not inside the data
grid and runat=server).
The update...
|
by: Ed Jay |
last post by:
I want to use history.go() to navigate between my previously loaded pages.
I'm looking for a way to trigger a function call when a page is accessed
using history.go(). Is there an event generated?...
|
by: Mesut |
last post by:
I have written a form in with radio buttons the name is set to orderby and the value is set to KundeVorName and the next value is KundeNachName and it goes so on. I wanna modify my query according...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |