I am trying to write a simple script to add data to a table but have not done PHP in a while so had to use the manuals. Anyways I thought I had this looking good but for some reason the script keep running thru all the code when the movie variable is empty.
<?php
if ($_POST['movie']){
include '../mconect.php';
if(!mysql_SELECT_DB('cafrow_movies')){
die("Could not Select Database Movies");
}
if (!MYSQL_Query("INSERT INTO movies SET movie='$_POST['movie']'")){
die("Could not Update Records");
}Else{
$updatemessage = $_POST['movie']. " has been added to the database";
}
mysql_close($mconnect);
}
echo $updatemessage;
?>
<form action="addmovie.php" method="post">
Movie Name: <input type="text" name="movie"><br>
<input type="Submit" name="submit" value="Add Movie">
</form>
The first If statment should be stoping the script from running the MySQL crap if it is empty, but I keep getting error about the MySQL trying to add data to the table but is not getting any info, well makes sence since the _Post[movie] is empty, I thought it would return false but it does not, I tried writting the if statement
if (!$_POST['movie'] == ""){
but I get the same error, I thought that if the IF condition was false it would skip the code that was within that condition.
thanks for any help.