//----confirm清单如下:
<html>
<head>
<title>Index</title>
</head>
<body>
<h2 align="center">User Registration Confirmation Page</h2>
<form name="registration" method="post" action="output.php" enctype="mutipart/form-data">
<table width="300" border="1" align="center" cellpadding="5" cellspacing="0" bgcolor="#CCCCCC">
<tr>
<td width="47%" align="right"> <B>Full Name </B> </td>
<td>
<?php
if( empty( $name ) )
{
die("Invalid name");
}
else
{
echo $name;
}
?>
</td>
</tr> <tr>
<td width="47%" height="57" align="right"> <B> Address </B></td>
<td height="57">
<?php
if(empty($address))
{
die("No address submitted");
}
elseif( ( strlen( $address ) < 5 ) || ( strlen( $address ) > 50 ) )
{
die("Invalid address");
}
else
{
echo $address;
}
?>
</td>
</tr>
<tr>
<td width="47%" align="right"> <B>email</B> </td>
<td height="2">
<?php
if( empty( $email ) )
{
die( " No email address submitted" );
}
elseif( ( strlen( $email) <5 ) || ( strlen( $email) > 50 ) )
{
die( "Invalid email address,email address too long or too short." );
}
elseif( !ereg( "@",$email ) )
{
die( "Invalid email address,no @ symbol found" );
}
else
{
echo $email;
}
?>
</td>
</tr>
<tr>
<td width="47%" align="right"> <B>password </B> </td>
<td height="2">
<?php
if( empty( $password ) || empty( $cpassword ) )
{
die( "No password submitted" );
}
elseif( ( ( strlen( $password ) < 5 ) || ( strlen( $password ) > 15 ) ) )
{
die( "Invalid password length address" );
}
elseif( !( strlen( $password ) == strlen( $cpassword ) ) )
{
die( "Password do not match!" );
}
elseif( ! ($password == $cpassword ) )
{
die( "Password do not match!" );
}
else
{
for( $i = 0;$i < strlen( $password );$i++ )
{
echo "*";
}
}
?>
</td>
</tr>
<tr>
<td width="47%" align="right" > <B>DoB </B> </td>
<td height="2">
<?php
if( empty( $birth_month ) || empty( $birth_day ) || empty( $birth_year ) )
{
die( "Date of birth not submitted or incomplete." );
}
switch( $birth_month )
{
case 1:print "January";break;
case 2:print "Febuary";break;
case 3:print "March";break;
case 4:print "April";break;
case 5:print "May";break;
case 6:print "June";break;
case 7:print "July";break;
case 8:print "August";break;
case 9:print "September";break;
case 10:print "October";break;
case 11:print "November";break;
case 12:print "December";break;
default:die( "Invalid birth month !!" );
}
if( ( $birth_day < 1 ) || ( $birth_day > 31 ) )
{
die( "Invalid date!" );
}
else
{
echo $birth_day," ";
}
if( ( $birth_year < 1900 ) || ( $birth_year > 2000 ) )
{
die( "Invalid birth year");
}
else
{
echo $birth_year;
}
?>
</td>
</tr>
<tr>
<td width="47%" align="right" >
Gender
</td>
<td height="2" width="26%" >
<?php
if( empty( $gender ) )
{
die( "Gender not specified" );
}
elseif( !( ( $gender == "Male" ) || ( $gender == "Female" ) ) )
{
die( "Invalid value for gender" );
}
else
{
echo $gender;
}
?>
</td>
</tr>
<tr>
<td width="47%" align="right" > <B> Topics of interests</B>
</td>
<td height="2" colspan="2">
<table width="100%" border="0">
<tr>
<td>
<?php
if( $fiction )
{
echo "fiction <br>";
}
if( $horror )
{
echo "horror <br>";
}
if( $action )
{
echo "action <br>";
}
if( $comedy )
{
echo "comedy <br>";
}
if( $thrillers )
{
echo "thrillers <br>";
}
?>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="47%" height="47" align="right"> <B> Select hobbies </B>
</td>
<td colspan="2" height="47">
<p align="center">
<?php
for( $i=0;$i < count( $hobbies );$i++ )
{
echo $hobbies[$i] ."<br>";
}
?>
</td>
</tr>
<tr>
<td colspan="3">
<FORM Name=confirm action="output.php">
<?php
echo "< input type=hidden name=\"name\"value\" ".$name."\" >\n";
echo "< input type=hidden name=\"address\"value\" ".$address."\" >\n";
echo "< input type=hidden name=\"email\"value\" ".$email."\" >\n";
echo "< input type=hidden name=\"birth_month\"value\" ".$birth_month."\" >\n";
echo "< input type=hidden name=\"birth_day\"value\" ".$birth_day."\" >\n";
echo "< input type=hidden name=\"birth_year\"value\" ".$birth_year."\" >\n";
echo "< input type=hidden name=\"interests\"value\" ".$interests."\" >\n";
for( $i=0;$i < count( $hobbies );$i++ )
{
echo "< input type=hidden name=\"hobbies[ ]\"value\" ".$hobbies[ $i ]."\" >\n";
}
if( $fiction )
{
echo "< input type=hidden name=\"fiction\"value\" ".$fiction."\" >\n";
}
if( $action )
{
echo "< input type=hidden name=\"action\"value\" ".$action."\" >\n";
}
if( $horror )
{
echo "< input type=hidden name=\"horror\"value\" ".$horror."\" >\n";
}
if( $comedy )
{
echo "< input type=hidden name=\"comedy\"value\" ".$comedy."\" >\n";
}
if( $thrillers )
{
echo "< input type=hidden name=\"thrillers\"value\" ".$thrillers."\" >\n";
}
?>
<center> <input="submit" name="Submit" value="Confirm >>">
</center>
</form>
</td>
</tr>
</table>
</form>
</body>
</html>麻烦各位了!
<html>
<head>
<title>Index</title>
</head>
<body>
<h2 align="center">User Registration Confirmation Page</h2>
<form name="registration" method="post" action="output.php" enctype="mutipart/form-data">
<table width="300" border="1" align="center" cellpadding="5" cellspacing="0" bgcolor="#CCCCCC">
<tr>
<td width="47%" align="right"> <B>Full Name </B> </td>
<td>
<?php
if( empty( $name ) )
{
die("Invalid name");
}
else
{
echo $name;
}
?>
</td>
</tr> <tr>
<td width="47%" height="57" align="right"> <B> Address </B></td>
<td height="57">
<?php
if(empty($address))
{
die("No address submitted");
}
elseif( ( strlen( $address ) < 5 ) || ( strlen( $address ) > 50 ) )
{
die("Invalid address");
}
else
{
echo $address;
}
?>
</td>
</tr>
<tr>
<td width="47%" align="right"> <B>email</B> </td>
<td height="2">
<?php
if( empty( $email ) )
{
die( " No email address submitted" );
}
elseif( ( strlen( $email) <5 ) || ( strlen( $email) > 50 ) )
{
die( "Invalid email address,email address too long or too short." );
}
elseif( !ereg( "@",$email ) )
{
die( "Invalid email address,no @ symbol found" );
}
else
{
echo $email;
}
?>
</td>
</tr>
<tr>
<td width="47%" align="right"> <B>password </B> </td>
<td height="2">
<?php
if( empty( $password ) || empty( $cpassword ) )
{
die( "No password submitted" );
}
elseif( ( ( strlen( $password ) < 5 ) || ( strlen( $password ) > 15 ) ) )
{
die( "Invalid password length address" );
}
elseif( !( strlen( $password ) == strlen( $cpassword ) ) )
{
die( "Password do not match!" );
}
elseif( ! ($password == $cpassword ) )
{
die( "Password do not match!" );
}
else
{
for( $i = 0;$i < strlen( $password );$i++ )
{
echo "*";
}
}
?>
</td>
</tr>
<tr>
<td width="47%" align="right" > <B>DoB </B> </td>
<td height="2">
<?php
if( empty( $birth_month ) || empty( $birth_day ) || empty( $birth_year ) )
{
die( "Date of birth not submitted or incomplete." );
}
switch( $birth_month )
{
case 1:print "January";break;
case 2:print "Febuary";break;
case 3:print "March";break;
case 4:print "April";break;
case 5:print "May";break;
case 6:print "June";break;
case 7:print "July";break;
case 8:print "August";break;
case 9:print "September";break;
case 10:print "October";break;
case 11:print "November";break;
case 12:print "December";break;
default:die( "Invalid birth month !!" );
}
if( ( $birth_day < 1 ) || ( $birth_day > 31 ) )
{
die( "Invalid date!" );
}
else
{
echo $birth_day," ";
}
if( ( $birth_year < 1900 ) || ( $birth_year > 2000 ) )
{
die( "Invalid birth year");
}
else
{
echo $birth_year;
}
?>
</td>
</tr>
<tr>
<td width="47%" align="right" >
Gender
</td>
<td height="2" width="26%" >
<?php
if( empty( $gender ) )
{
die( "Gender not specified" );
}
elseif( !( ( $gender == "Male" ) || ( $gender == "Female" ) ) )
{
die( "Invalid value for gender" );
}
else
{
echo $gender;
}
?>
</td>
</tr>
<tr>
<td width="47%" align="right" > <B> Topics of interests</B>
</td>
<td height="2" colspan="2">
<table width="100%" border="0">
<tr>
<td>
<?php
if( $fiction )
{
echo "fiction <br>";
}
if( $horror )
{
echo "horror <br>";
}
if( $action )
{
echo "action <br>";
}
if( $comedy )
{
echo "comedy <br>";
}
if( $thrillers )
{
echo "thrillers <br>";
}
?>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="47%" height="47" align="right"> <B> Select hobbies </B>
</td>
<td colspan="2" height="47">
<p align="center">
<?php
for( $i=0;$i < count( $hobbies );$i++ )
{
echo $hobbies[$i] ."<br>";
}
?>
</td>
</tr>
<tr>
<td colspan="3">
<FORM Name=confirm action="output.php">
<?php
echo "< input type=hidden name=\"name\"value\" ".$name."\" >\n";
echo "< input type=hidden name=\"address\"value\" ".$address."\" >\n";
echo "< input type=hidden name=\"email\"value\" ".$email."\" >\n";
echo "< input type=hidden name=\"birth_month\"value\" ".$birth_month."\" >\n";
echo "< input type=hidden name=\"birth_day\"value\" ".$birth_day."\" >\n";
echo "< input type=hidden name=\"birth_year\"value\" ".$birth_year."\" >\n";
echo "< input type=hidden name=\"interests\"value\" ".$interests."\" >\n";
for( $i=0;$i < count( $hobbies );$i++ )
{
echo "< input type=hidden name=\"hobbies[ ]\"value\" ".$hobbies[ $i ]."\" >\n";
}
if( $fiction )
{
echo "< input type=hidden name=\"fiction\"value\" ".$fiction."\" >\n";
}
if( $action )
{
echo "< input type=hidden name=\"action\"value\" ".$action."\" >\n";
}
if( $horror )
{
echo "< input type=hidden name=\"horror\"value\" ".$horror."\" >\n";
}
if( $comedy )
{
echo "< input type=hidden name=\"comedy\"value\" ".$comedy."\" >\n";
}
if( $thrillers )
{
echo "< input type=hidden name=\"thrillers\"value\" ".$thrillers."\" >\n";
}
?>
<center> <input="submit" name="Submit" value="Confirm >>">
</center>
</form>
</td>
</tr>
</table>
</form>
</body>
</html>麻烦各位了!
你还是看旧的资料来学PHP吧,建议你到www.php.net去下载最新的学习资料。
www.phpe.com也是一个好站点
希望我们一起进步。分数不是问题
所有表单提交的变量都使用$_POST数组引用,如
<input type="radio" name="gender" value="Female">
php程序中引用表单变量gender使用$_POST['gender']而不是用$gender。
当然你可以$gender = $_POST['gender'];然后再用$gender
将其改为 “register_globals = On”
如不想改 在后一个页面对于post方法用$HTTP_POST_VAR,get方法用$HTTP_GET_VARS存取前一个页面提交过来的值。
还有,可以将php.ini文件中error_reporting 段该成以下所显示那样。
; - Show all errors, except for notices
;
error_reporting = E_ALL & ~E_NOTICE
;
; - Show only errors
;
;error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR
;
; - Show all errors except for notices
;
;error_reporting = E_ALL; display all errors, warnings and notices
可以和上面一样,也可以象下面这样写
$name = $_POST['name'];//php4.10之后支持该用法,同时支持下面的用法
or
$name = $HTTP_POST_VARS['name'];//php4.10之前的用法
能不能请教一下到什么地方下载最新版本的php,能不能推荐一种好的php编辑器?
在没有在线帮助的情况下,迫使你认真对待每一行代码。从而使你的水平迅速提高。
初学应选择较稳定的版本php4.3.1就可以了。不要偷懒而去修改php建议的设置。
出于安全考虑没有几个isp供应商会提供register_globals = On的环境。
在php5中,HTTP_????_VARS也不再存在于全局数组里了。全局数组$GLOBALS中只有$_????变量组。这也是出于安全考虑,可杜绝通过全局数组获取服务器信息的途径。
您好!像我对Web开发毫无基础的情况下,我能不能学php?
刚才你说初学应选择稳定的版本php4.3.1,在哪里下载好?
学php必须有具备哪个条件才能迅速理解,谢谢!
<select name="hobbies[]" size="7" multiple>
<option value="Outdoor Sports">Outdoor Sports </option>
<option value="Adventure Sports">Adventure Sports </option>
<option value="Pop Music">Pop Music </option>
<option value="Rock Music">Rock Music </option>
<option value="Aggressive Music">Aggressive Music </option>
<option value="Photography">Photography </option>
</select>
在这里我定义了hobbies【】这个数组,我在confirm.php中引用时好像有问题,代码如下:
for( $i=0;$i < count( $_POST['hobbies'] );$i++ )
{
echo "< input type=hidden name=\"hobbies[ ]\"value\" ".$_POST['hobbies']."\" >\n";
}
其次,在我的多选框中有5项,我若是全部选定的话,就没有问题,若是缺少某一项的话,在confirm中就会给出该变量没有定义的错误信息,请问一下这又是什么原因?
急盼解决。谢谢大家了!
<?php
//echo count($_POST["hobbies"]);
for($i=0;$i<=6;$i++){
if($_POST["hobbies"][$i]!=""){
?>
<input type="text" name="<?php echo $_POST["hobbies"][$i]?>" value="<?php echo $_POST["hobbies"][$i]?>">
<?
}//if
}//for
?>
试试看!