好的,这是代码
PHP:
$rgen = mysql_real_escape_string(strip_tags($_POST['gender']));
$dobm = mysql_real_escape_string(strip_tags($_POST['dobm']));
$dobd = mysql_real_escape_string(strip_tags($_POST['dobd']));
$doby = mysql_real_escape_string(strip_tags($_POST['doby']));
$dab = $doby.$dobm.$dobd;
$tos = mysql_real_escape_string(strip_tags($_POST['TOS']));
HTML:
<select id=ftxti name=gender style="width:130px; padding: 10px 15px; height: 52px;" >
<option disabled selected >I'am</option>
<option value=0 >Male</option>
<option value=1 >Female</option>
</select>
<td>
</tr>
<tr>
<td class=dob >
<select name="dobm" id=ftxti style="width:103px;" >
<option disabled selected >Month</option>
<?php for ($i = 1; $i <= 12; $i++) : ?>
<option value="<?php echo ($i < 10) ? '0'.$i : $i; ?>"><?php echo $i; ?></option>
<?php endfor; ?>
</select>
<select name="dobd" id=ftxti style="width:95px;" >
<option disabled selected >Day</option>
<?php for ($i = 1; $i <= 31; $i++) : ?>
<option value="<?php echo ($i < 10) ? '0'.$i : $i; ?>"><?php echo $i; ?></option>
<?php endfor; ?>
</select>
<select name="doby" id=year style="width:95px;" >
<option disabled selected >Year</option>
<?php for ($i = 1980; $i < date('Y'); $i++) : ?>
<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
<?php endfor; ?>
</select>
<label >
<div id=tosag >
<input type=checkbox name=TOS value=1 />
<font style="font-size: 11px;" >
I agree to <a href=# style="color: rgb(50, 92, 129);">TOS</a>
</font>
</div>
</label>
错误:
Notice: Undefined index: gender in C:'xampp'htdocs'etc'e.conf'sys.proc'proc.reg'use.register.php on line 28
Notice: Undefined index: dobm in C:'xampp'htdocs'etc'e.conf'sys.proc'proc.reg'use.register.php on line 30
Notice: Undefined index: dobd in C:'xampp'htdocs'etc'e.conf'sys.proc'proc.reg'use.register.php on line 31
Notice: Undefined index: doby in C:'xampp'htdocs'etc'e.conf'sys.proc'proc.reg'use.register.php on line 32
Notice: Undefined index: TOS in C:'xampp'htdocs'etc'e.conf'sys.proc'proc.reg'use.register.php on line 36
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:'xampp'htdocs'etc'e.conf'sys.proc'proc.reg'use.register.php on line 101
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:'xampp'htdocs'etc'e.conf'sys.proc'proc.reg'use.register.php on line 109
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:'xampp'htdocs'etc'e.conf'sys.proc'proc.reg'use.register.php on line 118
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:'xampp'htdocs'etc'e.conf'sys.proc'proc.reg'use.register.php on line 126
如有任何帮助,我们将不胜感激。问题是,我似乎已经定义了索引,但我这里一定缺少一条规则,我对PHP有点生疏,所以请对我温和一点,而且我也是新来的,所以如果我做错了什么,我很抱歉。。。
如果没有看到所有的代码,很难猜测。。。但我会先检查一下,确保你的表格方法设置为张贴。
我以为Html和Php都在同一页上。在没有提交表单的情况下加载HTML页面时,所有PHP变量都是空的。就是这样。你需要这样写。
if(isset($_POST['gender'])){
$rgen = mysql_real_escape_string(strip_tags($_POST['gender']));
}
另一种方式,如果你想隐藏通知&警告,您可以在页面顶部添加以下代码。我不会在开发环境中建议这样做。
error_reporting(0);
(or)
ini_set( "display_errors", 0);
这可能不会解决任何问题。。。但你可能是想让<td>
成为</td>
<select id=ftxti name=gender style="width:130px; padding: 10px 15px; height: 52px;" >
<option disabled selected >I'am</option>
<option value=0 >Male</option>
<option value=1 >Female</option>
</select>
<td> <----- This should probably be a closing tag!
</tr>
你还应该在你的属性周围添加引号:
<a href=# should be <a href="#"
or
id=ftxti should be id="ftxti"
or
<option value=1 > should be <option value="1" >