So guys i'm trying to get a number from the input tag as shown below:
<form method="post" action="#">
<input type="number" name="delete" id="delete" maxlength="2" placeholder="Enter year in 2 digits" pattern="[0-9][0-9]" required="required">
<br> <br>
<div class="input-group">
<input type="submit" class="btn btn-primary btn-flat" value="Delete" name="del" id="del" />
</div>
</form>
After getting the value from the input tag, I use php to concatenate it with another string so I can obtain a proper output
if(isset($_POST['del']))
{
echo("<script>confirm('Are you sure?<br>Once deleted accounts cannot be recovered.')</script>");
$d=$_POST['delete'];
$yr='4so'.'$d'.'%';
echo ("<script>alert('$yr')</script>");
$query=mysqli_query($con,"delete * from student where usn like $yr;");
echo("<script>alert('Deleted.')</script>")
}
When I load my page containing this code the alert automatically displays, without me clicking the button at all.
Also another main issue I face is that when i click submit it doesnt display the value of $yr properly when using echo statement. In the image below if i enter 23 as input, in the alert it should display 4so.23.% but it displays 23 as %d