Jump to content

login script help please


jskoland

Recommended Posts

First I am very new to PHP. So this question is going to be very simple for you genius people out there. I have a simple login script. basically all I want is for someone to enter a password then continue on to the next page. BUT, when I go to the login in page and I enter the correct password, I go to the page I want but so does my login page. After I login I don't want the login page to follow me. How can I exit that and call my next page.

Thanks in advance
Link to comment
Share on other sites

[code]

<?php
include "open_session.php";
if(!isset($mainfile)) include ("mainfile.php");
include "config.php";

// Define your password
$password = "mypassword";

if ( $_POST['txtPassword'] != $password) {

?>

<h1>Login</h1>

<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <p><label for="txtpassword">Password:</label>
    <br /><input type="password" title="Enter your password" name="txtPassword" /></p>

    <p><input type="submit" name="Submit" value="Login" /></p>

</form>

<?php
}
else {
?>

<?php
header("location: mod.php?mod=newsletter&op=viewnewsletter&newsletterid=2");
break;
}
?>                   

[/code]
Link to comment
Share on other sites

"i dont think u can include like that."
Of course you can.


Can you show us a live example?
"I don't know what you mean by "My login page follows me".

I still don't know either.

Where is the processing for this form? It goes to itself, but doesn't do anything with the post data?
Link to comment
Share on other sites

ok I will try to explain myself a little better.
I go to my login in page and in the top left corner I have Login: and a password box under that to enter in my password and a submit button. Once I enter my password and click the submit button, I then get redirected to http://www.mydomain.com/mod.php?mod=newsletter?op=viewnewsletter&newsletterid=2/ through the header command in my login page. BUT, I also still see the Login text and the password box and submit button still in the left hand corner of my screen.
Link to comment
Share on other sites

IIRC, ./ means the root directory. I've never seen that in HTML.
you'll need to store the username in the session, then before printing the HTML form, check if the username is in the session. If it is, print it out, if not, print the form.
Link to comment
Share on other sites

I would think that there has to be something else going on since the rest of my pages work great. There has got to be something that says with successful login go here and not to include the page that I was just at. When I look at the source code after the redirection. I see the HTML code at the very top of the code then the rest of the code follows. Some  how I need to stop that from happening.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.