I moved my web app from development (local machine) to production (web server) and the script I have that inserts to the database won't work.
This is the script:
Could it be server settings?
This is the script:
Code:
<?php
include ('includes/DbCon.php');
//Set directory etc for image upload
$target_dir = "images/photo/";
$target_file = $target_dir . basename($_FILES["image"]["name"]);
if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file))
{
echo '<script type="text/javascript">';
echo 'alert("News Items Saved")';
echo '</script>';
} else {
echo "Sorry, there was an error with your file.";
}
// Variables
if (isset($_POST['headline']))$headline = $_POST['headline'];
if (isset($_POST['body']))$body = $_POST['body'];
if (isset($_POST['image']))$image = $_POST['image'];
//Insert into Db
if(isset($_POST['submit'])){
$query = "INSERT INTO news (`headline`, `body`, `image`)
VALUES ('$headline', '$body', '".$_FILES['image']['name']."');";
$result = $mysqli->query($query);
echo '<script type="text/javascript">';
echo 'document.location.href = "/admin/admin-news.php";';
echo '</script>';
}
else
{
echo '<script type="text/javascript">';
echo 'alert("The news item was not able to be created. Please try again."). mysql_error()';
echo '</script>';
}
$mysqli->close();
?>
Comment