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
https://forums.phpfreaks.com/topic/88283-solved-check-form-variables-then-process/
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');
}

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.