I have html form with post method. I want to pass the value of an input field in the url to the action page. I get undefined variable at first, but when I re-submit the form, I don't get undefined variable, I get the value I want. Here is the code.
<div class="col-md-6 p-2">
<?php
if(isset($_POST['search'])){
$keyword = $_POST['keyword'];
}
?>
<form method="post" action="search.php?keyword=<?php echo $keyword;?>">
<div class="input-group">
<input type="text" name="keyword" class="form-control" placeholder="Enter a keyword eg: chinese">
<div class="input-group-append">
<button type="submit" name="search" class="form-control btn btn-success"><i class="icofont-search"></i> Search Videos</button>
</div>
</div>
</form>
<p></p>
</div>
<form method="post" action="search.php?keyword=<?php echo $keyword;?>">