Jump to content

[SOLVED] Need help with a session and form thing.


SNN

Recommended Posts

I have tried multiple ways of using a session and a form, no luck at all.

Can anyone tell me how to properly use the code?

1st time
  if($_SESSION['user'] == "user" AND $_SESSION['pass'] == "pass")
2nd time
  if($_SESSION['user'] == "user" && $_SESSION['pass'] == "pass")
3rd time
  if($_SESSION['user'] == "user") { 
    if($_SESSION['pass'] == "pass") 

Oh and if this has anything to do with it, I have 4 things running on if/elseif.

Thanks for any help :)

uh, they all should work, but are you aware that forms use $_POST['data'] not sessions?

 

If you are coming from a form, then unless you convert the form POST data to SESSION data, that wont work...

 

Edit:

 

Heres an example.

 

Your form:

<form action="" method="">
<input type="text" name="user" />
<input type="password" name="pass" />
<input type="submit" value="Submit" />
</form>

 

The PHP:

If ($_POST['user'] == "George" && $_POST['pass'] == "s3Cr3t")
{
  echo "You entered George as a username and s3Cr3t as a password";
}

The script uses sessions, it was working before I added in more users/passes then it just started falling apart. It only uses $_POST to say that they entered a invalid user/pass.

I may just have to rewrite the script, because now it's giving me a unexpected $ error, which there is nothing there, so it's just messing up. Good thing it takes like 5 minutes..

I guess I'll post what I get after I rewrite the users section of the script.

That's weird, that's the exact type of form I set up.  :-\

I may just convert it over to a PHP and MySQL system, that would work a LOT better, I bet... especially for the posting system I am adding onto it.

I can do the MySQL coding, thanks for the help :)

uh, they all should work, but are you aware that forms use $_POST['data'] not sessions?

 

If you are coming from a form, then unless you convert the form POST data to SESSION data, that wont work...

 

Edit:

 

Heres an example.

 

Your form:

<form action="" method="">
<input type="text" name="user" />
<input type="password" name="pass" />
<input type="submit" value="Submit" />
</form>

 

The PHP:

If ($_POST['user'] == "George" && $_POST['pass'] == "s3Cr3t")
{
  echo "You entered George as a username and s3Cr3t as a password";
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.