标签:html表单上传
表单各项一定要加name属性,POST 和GET 取值都是通过name属性传参数获取的。不设置NAME属性获取不到值。
HTML JS PHP MYSQL 字符集 最好统一。
HTML JS PHP HTTP 请求方式必须统一。
举例:
html代码:
<form id="reg_form" method="post" action="reg_submit.php" onsubmit="return check_form(this)" name="reg_form"> <input type="text" id="username_input" name="username_input"onblur="check_username()" onkeyup="check_username()"/> <input type="text" id="email_input" name="email_input"onblur="check_email()" onkeyup="check_email()"/> <input type="password" id="password_input" name="password_input" onblur="check_password()" onkeyup="check_password()" /> <input type="password" id="repassword_input" name="repassword_input"onblur="check_repassword()" onkeyup="check_repassword()" /> <input type="text" id="name_input" name="name_input" /> <input type="submit" id="tijiao" value="" name="tijao"/> <input type="button" id="quxiao" value="" name="quxiao"/> <input type="hidden" id="username_check" value="0"/> <input type="hidden" id="email_check"/ value="0"> </form>
PHP代码:
<?php header("Content-type: text/html; charset=UTF-8"); error_reporting(0); $username_value = $_POST[‘username_input‘]; $email_value = $_POST[‘email_input‘]; $password_value=$_GET[‘password_input‘]; $name_value=$_POST[‘name_input‘]; include(‘data/conn.php‘); //$regdate = time(); $sql = "INSERT INTO t_user(f_username,f_email,f_password,f_name)VALUES(‘$username_value‘,‘$email_value‘,‘$password_value‘,‘$name_value‘)"; if(mysql_query($sql,$conn)){ echo $username_value; //echo $sql; 打印执行时的SQL语句 //echo $password_value;//打印传递的密码值 exit(‘用户恭喜注册成功!点击此处 <a href="login.html">登录</a>‘); } else { echo ‘抱歉!添加数据失败:‘,mysql_error(),‘<br />‘; echo ‘点击此处 <a href="javascript:history.back(-1);">返回</a> 重试‘; } ?>
本文出自 “郑树恒的技术博客” 博客,请务必保留此出处http://zhengshuheng.blog.51cto.com/1439780/1585743
标签:html表单上传
原文地址:http://zhengshuheng.blog.51cto.com/1439780/1585743