Simple Code Not Working
Posted: Tue Jun 29, 2010 2:55 pm
Hey everyone,
I have NO idea why the following code isn't executing the header command located in the if statement. I've put a echo in there to make sure it was evaluating correctly, and that printed as expected. I've also moved the header command elsewhere to make sure it worked, which it did. But for some reason this isn't working. The SQL is also executing and putting everything in the database as expected. The only thing that doesn't work is the header command and it only fails when it's placed inside the if statement, even though the if statement is true. I've used similar code tons of times with no problems and I'm getting frustrated with this. Any ideas?
I have NO idea why the following code isn't executing the header command located in the if statement. I've put a echo in there to make sure it was evaluating correctly, and that printed as expected. I've also moved the header command elsewhere to make sure it worked, which it did. But for some reason this isn't working. The SQL is also executing and putting everything in the database as expected. The only thing that doesn't work is the header command and it only fails when it's placed inside the if statement, even though the if statement is true. I've used similar code tons of times with no problems and I'm getting frustrated with this. Any ideas?
Code: Select all
<?php
if(isset($_POST['addNew'])) {
require("sources/connection.php");
$court_name = $_POST['model_name'];
$court_type = $_POST['height'];
$court_num = $_POST['weight'];
$eye_color = $_POST['eye_color'];
$city = $_POST['city'];
$state = $_POST['state'];
$country = $_POST['country'];
$interview = $_POST['interview'];
$gallery = $_POST['gallery'];
$video = $_POST['video'];
$test1 = $_POST['test1'];
$test2 = $_POST['test2'];
$test3 = $_POST['test3'];
$test4 = $_POST['test4'];
//$date_added = date ("Y-m-d H:i:s");
$sql = "INSERT INTO tester VALUES ('', '$court_name', '$court_type', '$court_num', '$eye_color', '$city', '$state', '$country', '$interview', '$gallery',
'$video', '$test1', '$test2', '$test3', '$test4')";
$result = $conn->query($sql) or die(mysqli_error());
if($result){
header("Location: cmsAdd.php?message=1");
}
else {
echo "Update was not successful";
}
}
?>