高分求php高手写一处理下面表单的代码
我是想让用户点击提交后,用户提交内容存入数据库,然后再在一个专门的php页面显示出来,最好能加上防止重复提交和过滤html等恶意代码的功能,小第是写不出来,唉,希望得到您...
我是想让用户点击提交后,用户提交内容存入数据库,然后再在一个专门的php页面显示出来,最好能加上防止重复提交和过滤html等恶意代码的功能,小第是写不出来,唉,希望得到您的帮助。
数据库地址:localhost;
数据库名称:root:
密码为:空; 表单的代码如下:
其实我是想让用户一提交表单,然后就转到另一个页面,让用户自己再看一下自己刚刚填写的内容,同时内容也提交到了数据库,就这样,没有什么注册之类的,只是一个提交表单到数据库,然后再在一个php页面显示来出,有会的帮帮忙了,写的详细的可以再加分的!
<formaction="zuche.php"method="post"name="yijiao">
<input type="hidden" name="hidden" value="yes">
<tablewidth="400"height="246"border="0"cellpadding="0"cellspacing="0"id="form">
<tr>
<td><tablewidth="100%"height="75"border="0"cellpadding="0"cellspacing="0">
<tr>
<tdheight="25">取车地点:</td>
<tdheight="25"><selectname="quche">
<optionvalue="0">请您选择在何处发车</option>
<optionvalue="1">东风路总店</option>
<optionvalue="2">体育路一分店</option>
</select></td>
</tr>
<tr>
<tdwidth="43%"height="25">取车方式:</td>
<tdwidth="57%"height="25"><inputname="mendianziqu"type="radio"value="radiobutton"chec
ked/>
门店自取
<label>
<inputtype="radio"name="shangmensongche"value="radiobutton"/>
上门送车</label></td>
</tr>
<tr>
<tdheight="25"><label>取车时间:</label></td>
<tdheight="25"><spanstyle="PADDING-LEFT:10px">
<label>
<inputname="birthday1"type="text"id="birthday1"size="8"maxlength="10"/>
</label>
日
<selectname="qucheshijian">
<optionvalue="1">01</option>
<optionvalue="2">02</option>
</select>
点</span></td>
</tr>
</table></td>
</tr>
<tr>
<tdvalign="top"></td>
</tr><tr><tdheight="30"><ahref="#">
<label><inputtype="submit"name="Submit"value="提交"/></label>
</a></td></tr>
</table>
</form> 展开
数据库地址:localhost;
数据库名称:root:
密码为:空; 表单的代码如下:
其实我是想让用户一提交表单,然后就转到另一个页面,让用户自己再看一下自己刚刚填写的内容,同时内容也提交到了数据库,就这样,没有什么注册之类的,只是一个提交表单到数据库,然后再在一个php页面显示来出,有会的帮帮忙了,写的详细的可以再加分的!
<formaction="zuche.php"method="post"name="yijiao">
<input type="hidden" name="hidden" value="yes">
<tablewidth="400"height="246"border="0"cellpadding="0"cellspacing="0"id="form">
<tr>
<td><tablewidth="100%"height="75"border="0"cellpadding="0"cellspacing="0">
<tr>
<tdheight="25">取车地点:</td>
<tdheight="25"><selectname="quche">
<optionvalue="0">请您选择在何处发车</option>
<optionvalue="1">东风路总店</option>
<optionvalue="2">体育路一分店</option>
</select></td>
</tr>
<tr>
<tdwidth="43%"height="25">取车方式:</td>
<tdwidth="57%"height="25"><inputname="mendianziqu"type="radio"value="radiobutton"chec
ked/>
门店自取
<label>
<inputtype="radio"name="shangmensongche"value="radiobutton"/>
上门送车</label></td>
</tr>
<tr>
<tdheight="25"><label>取车时间:</label></td>
<tdheight="25"><spanstyle="PADDING-LEFT:10px">
<label>
<inputname="birthday1"type="text"id="birthday1"size="8"maxlength="10"/>
</label>
日
<selectname="qucheshijian">
<optionvalue="1">01</option>
<optionvalue="2">02</option>
</select>
点</span></td>
</tr>
</table></td>
</tr>
<tr>
<tdvalign="top"></td>
</tr><tr><tdheight="30"><ahref="#">
<label><inputtype="submit"name="Submit"value="提交"/></label>
</a></td></tr>
</table>
</form> 展开
展开全部
表单问题,单选的多个选项应该用同一个name
你原来的
<tr>
<td width="43%"height="25">取车方式:</td>
<td width="57%"height="25"><input name="mendianziqu"type="radio"value="radiobutton"chec
ked/>
门店自取
<label>
<input type="radio"name="shangmensongche"value="radiobutton"/>
上门送车</label></td>
</tr>
改成
<tr>
<td width="43%"height="25">取车方式:</td>
<td width="57%"height="25"><input name="quchefangshi"type="radio"value="mendianziqu"chec
ked/>
门店自取
<label>
<input type="radio"name="quchefangshi"value="shangmensongche"/>
上门送车</label></td>
</tr>
/**************完整PHP代码如下 car.php***********************/
<?php
if ($_POST) {
$link = mysql_connect ( "localhost", "root", "这里是数据库密码" ); //自行修改密码
$sql_creat_db = 'create database IF NOT EXISTS `car`';
mysql_query ( $sql_creat_db );
mysql_query ( "SET NAMES 'GBK'");
mysql_select_db ( "car", $link ) or die ( '连接数据库失败' );
$sql_creat_table = '
create table IF NOT EXISTS `getcar`(
`id` int(11) NOT NULL auto_increment,
`quchedidian` varchar(150) NOT NULL,
`quchefangshi` varchar(50) NOT NULL,
`birthday1` varchar(50) NOT NULL,
`qucheshijian` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM
';
mysql_query ( $sql_creat_table ) or die ( '连接数据库失败' );
if (preg_match ( "/^[\d]+$/", $_POST ['birthday1'] )) {
$birthday = intval ( $_POST ['birthday1'] );
if ($birthday > 31 || $birthday < 1) {
echo '取车时间输入错误,只能输入数字';
} elseif ($_POST ['quchedidian'] == '0') {
echo '请选择取车地点';
} elseif (! isset ( $_POST ['quchefangshi'] )) {
echo '请选择取车方式';
} else {
$sql_insert_table = "
insert into getcar values(
NULL,
'{$_POST['quchedidian']}',
'{$_POST['quchefangshi']}',
'{$birthday}',
'{$_POST['qucheshijian']}')
";
if (mysql_query ( $sql_insert_table )) {
echo '提交成功<br />', '您提交的数据是:<br />', '取车地点:', $_POST ['quchedidian'], '<br />', '取车方式:', $_POST ['quchefangshi'], '<br />', '取车时间:', $birthday . '日' . $_POST ['qucheshijian'], '点<br />';
} else echo $sql_insert_table ;
;
}
} else {
echo '取车时间输入错误,只能输入数字';
}
}
?>
<form action="" method="post" name="yijiao"><input type="hidden"
name="hidden" value="yes">
<table width="400" height="246" border="0" cellpadding="0"
cellspacing="0" id="form">
<tr>
<td>
<table width="100%" height="75" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td height="25">取车地点:</td>
<td height="25"><select name="quchedidian">
<option value="0">请您选择在何处发车</option>
<option value="东风路总店">东风路总店</option>
<option value="体育路一分店">体育路一分店</option>
</select></td>
</tr>
<tr>
<td width="43%" height="25">取车方式:</td>
<td width="57%" height="25"><input name="quchefangshi" type="radio"
value="门店自取" chec ked /> 门店自取 <label> <input type="radio"
name="quchefangshi" value="上门送车" /> 上门送车</label></td>
</tr>
<tr>
<td height="25"><label>取车时间:</label></td>
<td height="25"><span style="PADDING-LEFT: 10px"> <label> <input
name="birthday1" type="text" id="birthday1" size="8" maxlength="10" />
</label> 日 <select name="qucheshijian">
<option value="1">01</option>
<option value="2">02</option>
</select> 点</span></td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top"></td>
</tr>
<tr>
<td height="30"><label><input type="submit" name="Submit" value="提交" /></label>
</td>
</tr>
</table>
</form>
你原来的
<tr>
<td width="43%"height="25">取车方式:</td>
<td width="57%"height="25"><input name="mendianziqu"type="radio"value="radiobutton"chec
ked/>
门店自取
<label>
<input type="radio"name="shangmensongche"value="radiobutton"/>
上门送车</label></td>
</tr>
改成
<tr>
<td width="43%"height="25">取车方式:</td>
<td width="57%"height="25"><input name="quchefangshi"type="radio"value="mendianziqu"chec
ked/>
门店自取
<label>
<input type="radio"name="quchefangshi"value="shangmensongche"/>
上门送车</label></td>
</tr>
/**************完整PHP代码如下 car.php***********************/
<?php
if ($_POST) {
$link = mysql_connect ( "localhost", "root", "这里是数据库密码" ); //自行修改密码
$sql_creat_db = 'create database IF NOT EXISTS `car`';
mysql_query ( $sql_creat_db );
mysql_query ( "SET NAMES 'GBK'");
mysql_select_db ( "car", $link ) or die ( '连接数据库失败' );
$sql_creat_table = '
create table IF NOT EXISTS `getcar`(
`id` int(11) NOT NULL auto_increment,
`quchedidian` varchar(150) NOT NULL,
`quchefangshi` varchar(50) NOT NULL,
`birthday1` varchar(50) NOT NULL,
`qucheshijian` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM
';
mysql_query ( $sql_creat_table ) or die ( '连接数据库失败' );
if (preg_match ( "/^[\d]+$/", $_POST ['birthday1'] )) {
$birthday = intval ( $_POST ['birthday1'] );
if ($birthday > 31 || $birthday < 1) {
echo '取车时间输入错误,只能输入数字';
} elseif ($_POST ['quchedidian'] == '0') {
echo '请选择取车地点';
} elseif (! isset ( $_POST ['quchefangshi'] )) {
echo '请选择取车方式';
} else {
$sql_insert_table = "
insert into getcar values(
NULL,
'{$_POST['quchedidian']}',
'{$_POST['quchefangshi']}',
'{$birthday}',
'{$_POST['qucheshijian']}')
";
if (mysql_query ( $sql_insert_table )) {
echo '提交成功<br />', '您提交的数据是:<br />', '取车地点:', $_POST ['quchedidian'], '<br />', '取车方式:', $_POST ['quchefangshi'], '<br />', '取车时间:', $birthday . '日' . $_POST ['qucheshijian'], '点<br />';
} else echo $sql_insert_table ;
;
}
} else {
echo '取车时间输入错误,只能输入数字';
}
}
?>
<form action="" method="post" name="yijiao"><input type="hidden"
name="hidden" value="yes">
<table width="400" height="246" border="0" cellpadding="0"
cellspacing="0" id="form">
<tr>
<td>
<table width="100%" height="75" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td height="25">取车地点:</td>
<td height="25"><select name="quchedidian">
<option value="0">请您选择在何处发车</option>
<option value="东风路总店">东风路总店</option>
<option value="体育路一分店">体育路一分店</option>
</select></td>
</tr>
<tr>
<td width="43%" height="25">取车方式:</td>
<td width="57%" height="25"><input name="quchefangshi" type="radio"
value="门店自取" chec ked /> 门店自取 <label> <input type="radio"
name="quchefangshi" value="上门送车" /> 上门送车</label></td>
</tr>
<tr>
<td height="25"><label>取车时间:</label></td>
<td height="25"><span style="PADDING-LEFT: 10px"> <label> <input
name="birthday1" type="text" id="birthday1" size="8" maxlength="10" />
</label> 日 <select name="qucheshijian">
<option value="1">01</option>
<option value="2">02</option>
</select> 点</span></td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top"></td>
</tr>
<tr>
<td height="30"><label><input type="submit" name="Submit" value="提交" /></label>
</td>
</tr>
</table>
</form>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询