Jump to content

When entering a form...


nimzie

Recommended Posts

How do I validate that I came from a certain form (i.e. in a login situation)...

I need to make sure that if people hit the URL to a page directly, that the only way they can come in is from the login screen...

 

 

Thanks for any help.

 

Adam

Link to comment
Share on other sites

You can check a form was submitted to the page via...

 

<?php

 if (isset($_POST['submit'])) {
   // process form.
 }

?>

 

Providing you have a submit button named form. You can also check the refering page using $_SERVER['HTTP_REFERER'], this can however be spooked. One method which may offer more security is to set a $_SESSION variable within the login form page, then check for its exeistence within the processing script.[/img]

Link to comment
Share on other sites

Use sessions.

Sessions could be spoofed, but to expand on this answer

 

at the top of your script do

 

<?php

sesson_start();

$_SESSION['verify'] = 'asdfasdfasdfasfasdfasdfasdfl';

 

 

then on the processing page do

 

<?php

session_start();

if($_SESSION['verify'] !== 'asdfasdfasdfasfasdfasdfasdfl'){

header("Location: http://www.website.com");

exit;

}

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.