Php 注册时检查错误
我在html中添加了一个动态选择器,用于在注册时选择性别和国家,现在的问题是如何使用IF和Else速记来检查用户是否同时选择了这两个选项,以便注册完成 这是我添加的选择器Php 注册时检查错误,php,html,Php,Html,我在html中添加了一个动态选择器,用于在注册时选择性别和国家,现在的问题是如何使用IF和Else速记来检查用户是否同时选择了这两个选项,以便注册完成 这是我添加的选择器 <div>Gender:</div> <select id="gender" onfocus="emptyElement('status')"> <option value=""></option> <option value="
<div>Gender:</div>
<select id="gender" onfocus="emptyElement('status')">
<option value=""></option>
<option value="m">Male</option>
<option value="f">Female</option>
</select>
<div>Country:</div>
<select id="country" onfocus="emptyElement('status')">
<?php include_once("country_list.php"); ?>
</select>
<div>
性别:
男性的
女的
国家:
必须在表单输入中添加名称
属性
<select id="gender" name="gender" onfocus="emptyElement('status')">
<select id="country" name="country" onfocus="emptyElement('status')">
希望这会有所帮助。首先,您需要一个
name
属性,以便PHP处理它<除非使用javascript/jquery进行验证,否则代码>id将毫无用处。好的,谢谢。。。我觉得这个和我想的很接近,很相似,让我试试看。如果你需要更多的帮助,请告诉我。
if(!isset($_POST['gender']))
{
//Do what you need to if it is not set (such as a redirect)
}
if(!isset($_POST['country']))
{
//Do what you need to if it is not set (such as a redirect)
}