Why dose this not work? When I submit a emty form
if((!isset($uname)) || (!isset($passw))) {
header("Location: ../pub-login.php");
$_SESSION[validate] = "Entry not recognized";
exit();
}
Why dose this not work? When I submit a emty form
if((!isset($uname)) || (!isset($passw))) {
header("Location: ../pub-login.php");
$_SESSION[validate] = "Entry not recognized";
exit();
}
Could you please tell us more what happens when you submit the form?
- Do you get a blank white page?
- Do you get an error message?
Regards
Why dose this not work? When I submit a emty form
if((!isset($uname)) || (!isset($passw))) { header("Location: ../pub-login.php"); $_SESSION[validate] = "Entry not recognized"; exit(); }
What error message are you getting?
I going to take a quick guess on to what your problem might be... the header("Location: ../pub-login.php"). If I'm correct, here's why. (copied fromhttp://php.net/manual/en/function.header.php)
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.
<html>
<?php
/* This will give an error. Note the output
* above, which is before the header() call */
header('Location: http://www.example.com/');
?>
to fix this problem I would suggest doing the login on another page. for example, when the user clicks the login link, it brings the user to login_verify.php and in that page verify and redirect to your desired page, and make sure that the header comes before any HTML. hope this helps
Have you defined the variables "$uname" and "$passw"?
<?php
/* Your Variables */
$uname = $_POST['username'];
$passw = $_POST['password'];
?>
Regards
Hi,
Why thinking so hard
Just check if values is empty go login page.
if($username == "" || $password == ""){
Do something
}else{
Do something
}
OR
We can use isset also. But here no need i think. Just for checking values whether is null or not null.
may be you can check like
if(isset($username) && isset($password)){
Do something
}else{
Do something
}
Thanks
William
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.