Jump to content

[SOLVED] Check form variables then process


ramsfield

Recommended Posts

I have a search form page, which sends data to page that sets cookies, then redirects to the search results.

 

What I would like to do is first check to see if 1 of the 5 form fields that was submitted to the setcookie page has something in it. If none are set, then return them to the search page. If at least 1 or more are set, send them to the search results page.

Link to comment
Share on other sites

Thanks for your help, below is what I used to get it to work

 

if(empty($_POST['txtcaseno']) && empty($_POST['txtparcel']) && empty($_POST['txtlname']) && empty($_POST['txtfname']) && empty($_POST['txtstreet'])){
header('Location: index.php');
exit();
} else {

$caseno = $_POST['txtcaseno'];
$parcelno= $_POST['txtparcel'];
$lname= $_POST['txtlname'];
$fname= $_POST['txtfname'];
$street= $_POST['txtstreet'];

$time = time();                
// Gets the Current Server Time

setcookie("MasonCoPermits[caseno]", $caseno, $time + 3600);    

setcookie("MasonCoPermits[parcelno]", $parcelno, $time + 3600);    

setcookie("MasonCoPermits[lname]", $lname, $time + 3600);   

setcookie("MasonCoPermits[fname]", $fname, $time + 3600);   

setcookie("MasonCoPermits[street]", $street, $time + 3600);   

header('Location: search_results.php');
}

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.