I have a project where I need to take values from an html checkbox to determine which page I need to go to. I coded like this but that is not really working.
<?php
$db_host = 'localhost'; // Server Name
$db_user = 'root'; // Username
$db_pass = ''; // Password
$db_name = 'assign'; // Database Name
$conn = mysqli_connect($db_host, $db_user, $db_pass, $db_name);
if (!$conn) {
die ('Failed to connect to MySQL: ' . mysqli_connect_error());
}
?>
<html>
<body>
<div class="form-style-8">
<center><h2>Make a Choice</h2></center>
<form action="/action_page.php">
<input type="checkbox" name="chc" value="bat"> Batting<br>
<input type="checkbox" name="chc" value="bwl"> Bowling<br>
<input type="checkbox" name="chc" value="fld"> Fielding<br><br>
<input type="submit" value="Submit">
</form>
</div>
</body>
<?php
if($_POST['chc'] == 'bat'){
echo '<a href="Attatchment 1.php">Batting</a>';
}
?>
</html>
If someone can help me understand how I can just open the php page with the checkbox ticking Batting, I believe I can finish the rest.