所以我们正在尝试从输入标签中获取一个数字,如下所示:
<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>
从输入标记获取值后,我使用php将其与另一个字符串连接,以便我可以获得正确的输出
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>")
}
当我加载包含此代码的页面时,警报会自动显示,而我根本不会单击该按钮。
我面临的另一个主要问题是,当我点击提交时,它在使用echo语句时不会正确显示$ yr的值。如果我输入23作为输入,则在下图中,在警报中它应显示4so.23。%但显示23为%d