Form validation in php when form action is another page (php code). How do I validate the form and display error message in view page?
view page
<html>
<body>
<form action="redirect.php" method="POST" enctype="multipart/form-data">
<label for="name"><b>Name: </b></label>
<input type="text" name="name" id="name" >
<br>
<label for="email"><b>Email: </b></label>
<input type="text" name="email" id="email" >
<br>
<label for="email"><b>Project Type: </b></label>
<input type="text" name="projecttype" id="projecttype">
<br>
<label for="email"><b>Project Description: </b></label>
<input type="text" name="pdescription" id="pdescription" >
<br>
<label for="file"><b>File Upload: </b></label>
<input type="file" name="file" id="file">
<br>
<div class="clearfix">
<input type="submit" name="submit1" id="submit1" value="submit1">
</div>
</form>
</body>
</html>
redirect.php
<?php
if(isset($_POST['submit1']))
{
$name=$_POST['name'];
$email=$_POST['email'];
$projecttype=$_POST['projecttype'];
$projectdetails=$_POST['pdescription'];
$attachment=$_FILES['file']['name'];
$tmp_name=$_FILES['file']['tmp_name'];
move_uploaded_file($tmp_name,"upload/".$attachment);
$query=mysql_query("insert into projectdetails(Customer_name,Customer_email,Customer_attachment,Customer_project_type,Customer_project_details) values('$name','$email','$attachment','$projecttype','$projectdetails')");
if($query)
{
header('Location: test2.php');
}
?>