I want to go to other php page on pressing html button of same site. I have tried it by using header function but it was not working.
Here is the simple html code:
<input type="button" name="Insert_Ad" value="Post and ad">
If user clicks this button it will take it to another php page For Example with URL adddress 'http://localhost/Product.php/Product.php'
Here is the code of that PHP page to which I want to go on pressing button
<html>
<head>
<meta charset="UTF-8">
<title>Insert form data</title>
</head>
<body>
<form method="post" action ="Product.php" id="contact-form">
<input type="text" name="product_category" placeholder="product_category" required />
<input type="text" name="product_name" placeholder="product_name" required />
<textarea id = "address" name="product_description" placeholder="product_description" required /></textarea>
<input type="text" name="product_image1" placeholder="product_image1" required />
<input type="text" name="product_image2" placeholder="product_image2" required />
<input type="text" name="product_image3" placeholder="product_image3" required />
<input type="text" name="product_image4" placeholder="product_image4" required />
<input type="text" name="product_image5" placeholder="product_image5" required />
<div class="btn-group" role="group">
<input type="submit" class="btn btn-default" name="Add" value="Enter the box" style="margin-top: 15px; margin-right: 15px; border-radius: 4px;">
</div>
</form>
<?php
$servername = "localhost";
$username = "root";
$password = "zz224466";
$dbname = "zain";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if(isset($_POST['Add']))
{
$product_category = $_POST['product_category'];
$product_name = ($_POST['product_name']);
$product_description = ($_POST['product_description']);
$product_image1 = ($_POST['product_image1']);
$product_image2 = ($_POST['product_image2']);
$product_image3 = ($_POST['product_image3']);
$product_image4 = ($_POST['product_image4']);
$product_image5 = ($_POST['product_image5']);
$sql = "INSERT INTO zain.product (product_category,product_name,product_description,product_image1,product_image2,product_image3,product_image4,product_image5)
VALUES ('$product_category','$product_name','$product_description','$product_image1','$product_image2','$product_image3','$product_image4','$product_image5')";
mysqli_query($conn,$sql);
if (mysqli_query($conn,$sql))
{
echo "New record created successfully";
}
else
{
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
}
?>
</body>
</html>
Kindly help me how to do that