Code: Select all
<form method = "post" name = "registrationForm" action ="validateForm.php">
<input type ="text" name = "txtUserName"></input>
<input type="password" name = "txtPassword"></input>
</form>Note:
I have read the jason's tutorial about redirecting user using header() function. But in my case, the header has been sent to the output. And I am wondering if there is another way to redirect user in my case.
Thank you very much,
Chris
Code: Select all
<?php
session_start();
$_SESSION['username'] = $_POST['txtUserName'];
$_SESSION['password'] = $_POST['txtPassword'];
/**
* function to check form validity
* @return boolean
*/
function checkValidity() {
//the logic here...
}
$isAllValid = checkValidity();
if ($isAllValid) {
//redirect user using Javascript
echo '<script src = "validations.js" type = "text/javascript"></script>';
echo '<script language = "javascript" type = "text/javascript">';
echo 'redirectUser("registrationCompleted.php");';
echo '</script>';
}
?>