Jump to content

Form - kind of deloggin users


Atomg

Recommended Posts

Hi all, (hope the little french word won't bug you guys)

I have put a form that let any users to send me comments about my website. It is a normal form.. well I think. Their is a problem when we click the submit button.

This is the situation:
[list]
[*]We are logged.
[*]We go in support section, where we can fill the form (name, your mail, your message).
[*]You clic the submit button.
[*]You are redirected to a page that says to you that everything was fine and the e-mail was sent.
[*](problem now) If we try to access private section (where you need to be logged in) it does not work anymore. Seems like you have been "unlogged" by sending the form.
[*]I say "OK, let's RELOG". I go in the log in form, log in. And I CAN'T log in. The only way to log in back, is to call the session_destroy() function and then to log in back.
[/list]

????WHY????

This is the form, how it calls my page. (the support.php page (where you fill in the form) will call the envoie.php page (Where this page have the mail() function))

[code]<form action="index.php?page=envoie" method="post">[/code]

I always call index.php and verify the page variable. If it is a private page, I verify the user is logged in before showing something.

Also, at each start of my page, I verify the session state like this (if it is not good, say plz):

[code]session_start();

if($_GET['cmd'] == "logout") {
    session_destroy();
}

$auth = false;
$auth2 = false;

if(isset($_SESSION['nom']))
{
    $nom = $_SESSION['nom'];
   
    if($nom == 'theusername') {
        $auth = true;
    } else if($nom == 'another username') {
        $auth2 = true;
    }
}
else
{
    $nom = $_POST['nom'];
    $pwd = $_POST['pw'];
   
    // Verify login
    if($nom == "username" & $pwd == "password")
    {
        $_SESSION['nom'] = $nom;
        $auth = true;
    }
    else if($nom == "anotheruser" & $pwd == "anotherpass")
    {
        $_SESSION['nom'] = $nom;
        $auth2 = true;
    }
}[/code]

Please, if you guys need more info, say and I will give.

Thank you for all the help.
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.