Jump to content

POST and GET help


dave25

Recommended Posts

How do add $_GET['return'] to get output $input['return'] like i have $input['username'] and add value null if no return url detected?

<?php

$errors = array();
/* Form is not submitted */
$input = array(
    'username' 	=> NULL,
    'password' 	=> NULL,
    'remember' 	=> NULL
);
/* Form is submitted */
if(filter_has_var(INPUT_POST, 'submit')){
	
	$defs_POST = array(
	    'username' 	=> FILTER_SANITIZE_STRING,
	    'password'	=> FILTER_UNSAFE_RAW,
	    'remember'	=> FILTER_SANITIZE_STRING
	);
	
	$input = filter_input_array(INPUT_POST, $defs_POST);
	
	if(empty($input['username'])){
	    $errors[] = 'Please enter your username.';
	}
	if(empty($input['password'])){
            $errors[] = 'Please enter your password.';
    }
	
}

if(filter_has_var(INPUT_POST, 'submit') and empty($errors)){
	
	print "Username = '".$input['username']."', Password = '".$input['password']."', Remember = '".$input['remember']."', Return = '".$input['return']."'";
	
	/*
	if(!empty($input['return']))
	    redirect(urldecode($input['return']));
	else
	    redirect('index.php?do=home');
	*/
}
	
print "
<form method='post'>
Username <input type='text' name='username' value='".$input['username']."'><br>
Password <input type='text' name='password' value='".$input['password']."'><br>
Remember me <input type='checkbox' name='remember' value='Yes'><br>
<input type='submit' name='submit' value='SUBMIT'>
</form>";

?>
Link to comment
https://forums.phpfreaks.com/topic/295951-post-and-get-help/
Share on other sites

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.