本文介绍了为什么我的PHP代码没有插入:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 您好 我想插入我的数据库但由于某种原因它不会插入。由于某种原因,它无法正常工作,它无法工作啊意味着它停止在数据库中插入名称。当我运行它将返回我的根页面啊意味着索引页面但注册表单的信息没有插入数据库,这是我想要它做的。 可以有人为我投三分之一因为我错过了一些东西而且我必须在今晚午夜之前提出这个问题 这里是我所拥有的 我尝试过: < pre > <? php if( isset($ _ POST [' 输入'])) { // 从表单中捕获变量并存储在php变量中 $ title = $ _ POST [' title']; $ firstname = $ _ POST [' firstname']; $ lastname = $ _ POST [' lastname']; $ username = $ _ POST [' username']; $ email = $ _ POST [' email']; $ gender = $ _ POST [' gender']; $ address = $ _ POST [' address']; $ mypwd = $ _ POST [' mypwd']; 包括' db_server.php' ; // 选择要查询的数据库 $ sql = SELECT * FROM members WHERE username ='$ username'; $ result = mysqli_query($ conn,$ sql)或 die( 错误: .mysqli_error()); $ rowcount = mysqli_num_rows($ result); if($ rowcount> = 1) // 检查用户名是否已经存在 { echo < script type = \text / javascript \> alert('用户名已经退出'); window.location = \../ login_user.html \; < / script>; } 其他 { // 将数据插入表中 $ sql = INSERT INTO成员 VALUES('$ title','$ firstname','$ lastname','$ username','$ email' ,'$ gender','$ address',md5('$ mypwd')); if(mysqli_query($ conn,$ sql)) { mysqli_close($ conn); echo <脚本类型= \text / javascript \> alert('用户名已退出'); window.location = \../ index.html \; < / script>; } else { echo 将值插入数据库; } // 行尾 } } ?> 解决方案 _POST [' 输入'])) { // 从表单中捕获变量并存储在php变量中 title = _POST [' title']; hi therei am trying to insert into my database but for some reason it will not insert. it was working good a while aback for some reason it will not work ah mean it stop inserting names into the database. when I run it it will go back to my root page ah mean the index page but the information frm the registration form is not inserting into the database which is what I want it to do.can someone throw a third eye for me cuz iike i am missing something and i have to hand this up by midnight tonighthere is what i haveWhat I have tried:<pre><?phpif(isset($_POST['enter'])){//capture the variable from the form and store in php variables$title=$_POST['title'];$firstname=$_POST['firstname'];$lastname=$_POST['lastname'];$username=$_POST['username'];$email=$_POST['email'];$gender=$_POST['gender'];$address=$_POST['address'];$mypwd=$_POST['mypwd'];include'db_server.php';//select the database you want to query$sql="SELECT * FROM members WHERE username='$username'";$result= mysqli_query($conn, $sql) or die ("ERROR:" .mysqli_error());$rowcount=mysqli_num_rows($result);if($rowcount >= 1) //checking to see if usernamename is already exist{ echo "<script type=\"text/javascript\"> alert('Username already exits'); window.location=\"../login_user.html\"; </script>";}else{//insert data into table$sql = "INSERT INTO membersVALUES('$title', '$firstname', '$lastname', '$username', '$email', '$gender', '$address', md5('$mypwd'))";if(mysqli_query($conn,$sql)){mysqli_close($conn);echo "<script type=\"text/javascript\"> alert('Username already exits'); window.location=\"../index.html\"; </script>";}else{echo "Error inserting values into database";}//end of line}}?> 解决方案 _POST['enter'])){//capture the variable from the form and store in php variablestitle=_POST['title']; 这篇关于为什么我的PHP代码没有插入:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-05 12:18
查看更多