SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
Thread: Simple Form Validation
Threaded View
-
Jun 9, 2007, 06:21 #1
- Join Date
- Jun 2007
- Posts
- 28
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Simple Form Validation
Im trying to validate this form.... for some reason, when i dont fill out any fields, yet i have the password field right, $ok == "true" when it should be false if no fields are filled out... Can anyone find the problem?
PHP Code:<?
include("header.php");
$reply = "Please fill out the form below to add a new movie to the site.<br>";
if(isset($_POST['submit'])){
$pass = $_POST['pass'];
$access = "123";
$ok = "true";
if($pass != $access){
$ok = "false";
$reply = $reply."<br> - The password you entered is incorrect. Please enter the correct password to continue<br>";
} else {
$title = $_POST['title'];
$title = str_replace(" ", "_", $title);
$year = $_POST['year'];
$syn = $_POST['syn'];
$blank = "";
function validate($item){
if($item == $blank){
$ok = "false";
$reply = $reply."<br> - You need to fill out all of the required fields.<br>";
}
}
validate("$title");
validate("$year");
validate("$syn");
}
if($ok == "true"){
$reply = "<b>Your movie information has been added successfully!</b>";
} else if ($ok != "true"){
$reply = $reply."<br> - Your movie info couldn't be added. Make sure you fill out all the required fields, and that the formats are right.<br>";
}
}
?>
then it echo's the reply:
<div id="reply">
<p><strong>Form Guide<br />
</strong><? echo $reply; ?></p>
</div>
Bookmarks