I am working on form that submits data to log them in. The submit button takes them to members.php
On that page I have some code that makes sure the username and password are set or it sets them to Null
Now I want to test for null and if it is null send them back to login.php
Here is the part of the members.php that deals with the form variable from login.php:
<?php
session_start();
// include function files for this application
require_once('includes/error_fns.php5');
//create short variable names
$username = (isset($_POST['username'])) ? $_POST['username'] : NULL;
$passwd = (isset($_POST['passwd'])) ? $_POST['passwd'] : NULL;
Should I then do an if statement something like this?
if ($username ===NULL || $passwd ===NULL) {
// need to redirect them to login.php
}
Would that be the way to test this to make sure I have values, and if so, then how do I return them back to the other page?
Would it be better to put this ahead of the first part of the code more like this?
<?php
session_start();
// include function files for this application
require_once('includes/error_fns.php5');
//Test for form variables filled out:
IF (!isset($_POST['username']) ||!isset($_POST['passwd']) )
{
// redirect them back to login
}
else
//create short variable names
$username = $_POST['username'] ;
$passwd = $_POST['passwd'];