I have this code in my form:
<form id="addForm" action="php/add-article.php" method="POST" enctype="multipart/form-data">
<table>
<tr>
<td class="tableLeft">Article Photo:</td>
<td class="tableRight"><input id="formPhoto" class="addTextInput" name="photo" type="file" /></td>
<td id="validatePhoto"></td>
</tr>
<tr>
<td class="tableLeft">Article Photo Alt:</td>
<td class="tableRight"><input id="formAlt" class="addTextInput" name="alt" type="text" /></td>
<td id="validateAlt"></td>
</tr>
<tr>
<td class="tableLeft">Article Title:</td>
<td class="tableRight"><input id="formTitle" class="addTextInput" name="title" type="text" /></td>
<td id="validateTitle"></td>
</tr>
<tr>
<td class="tableLeft">Article Body:</td>
<td class="tableRight"><textarea id="formArticle" class="addTextInput" rows="6" name="article"></textarea></td>
<td id="validateArticle"></td>
</tr>
<tr>
<td class="tableLeft"></td>
<td id="validateSending" class="tableRight"></td>
</tr>
<tr>
<td class="tableLeft"></td>
<td class="tableRight"><input id="formSubmit" class="addSubmitInput" type="submit" value="Add This" /></td>
</tr>
</table>
</form>
And this in a php file (add-article.php):
<?php
$time = time();
$id= time().''.mt_rand(1000, 9999);
$year = date("Y");
$path = "../images/$year/";
$title = ucwords($_POST['title']);
$article = $_POST['article'];
$alt = $_POST['alt'];
$extension = end(explode(".", $_FILES["photo"]["name"]));
$added = date("Y-m-d H:i:s");
$views = "0";
?>
<?php
$insert_post_sql = "INSERT INTO articles (id, photo, alt, title, article, added, views) VALUES('$id', '.$extension', '$alt', '$title', '$article', '$added', '$views')";
$insert_post_res = mysqli_query($con, $insert_post_sql);
if(mysqli_affected_rows($con)>0){
move_uploaded_file($_FILES["photo"]["tmp_name"],"$path" . $id . "." . $extension);
header("Location: ../article.php?id=$id");
exit();
}
else{
echo "0";
};
?>
When I run this on my localhost, everything works compltely fine yet when I do it on my live site it echo's 0
and says that photo, alt, title and article are uindefined.
Does anyone know what the reason for this might be?