Jump to content

Recommended Posts

Hi Guys,

 

I have 2 pages, a form (form.php), and a script (process.php). Now what I want to do is, if someone tries to directly access process.php then he will get redirected back to form.php, but if a user submitts a form via form.php then it will get processed by process.php - How can I do this ?

Link to comment
https://forums.phpfreaks.com/topic/73384-_post/
Share on other sites

You could check the $_SERVER['HTTP_REFERER'], but this isn't 100% reliable.

 

You could set a session variable on form.php, and check for it on process.php. If it's not there, then they didn't go to form.php first. That solution only works once though.

 

Or, you could set a hidden variable to pass through, and check for that.

<input type="hidden" name="valid_user" value="true" />

 

Or, you could check that all the fields have been set (or at the least the ones that have to), and if they're not... send them back to form.php.

<?php
if(!isset($_POST['name']))
    header("Location: URL/form.php"); // They didn't enter their name or they came to process.php directly!

Link to comment
https://forums.phpfreaks.com/topic/73384-_post/#findComment-370259
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.