I’m trying to invoke job.php from careers.php using the code below. Could someone help me identify what might be wrong or suggest a better approach?
careers.php:
<div class="trending-lower-text d-flex align-items-center justify-content-between">
<a class="custom-btn btn1" href=“aform.php"><span>Apply</span></a>
<form id="hiddenForm" action="job.php" method="post">
<input type="hidden" name="jobTitle" value="SoftwareEngineer">
<button type="submit" class="custom-btn btn2"><span>Read More</span></button>
</form>
</div>
job.php
<?php include_once '../../includes/header.php';
if (isset($_POST['jobTitle'])) {
$title = htmlspecialchars($_POST['jobTitle']); // Retrieve the value from the form
?>
2
Answers
If you switch to using a link instead of a form, it would make things simpler:
careers.php:
job.php
I think You missed Curly braces in job.php that’s why you don’t access your variable and i echo variable it works after adding curly braces
As i runs this code at my own end.
Code: