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
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.