如何摆脱或修复此错误? [英] How do I get rid of or fix this error?

查看:85
本文介绍了如何摆脱或修复此错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用javascript验证我的注册表单,但我想通过使用:alert('it works)来查看js是否正在运行表单但我收到此错误



注意:未定义索引:c中的性别;



与php代码有关。到我的js是没有功能,直到错误修复,尝试了我能想到的一切,甚至搜索网络并尝试了所有我能看到但无济于事



can有人帮忙,也没有插入数据库,可以告诉我什么是错的,以及为什么它没有插入数据库



也许第三只眼睛会帮助我这是什么不插入数据库,我得到各种我看不到的错误,当我运行它时给我错误的结果



当我的意思错误的结果,我的意思是当用户注册它时,弹出框会弹出并告诉你欢迎来到网页然后它应该将用户重定向到登录页面而不是这样做,而是告诉用户用户名已经存在(我在代码本身中没有),它要么将你带回索引页面,要么返回到注册页面不应该这样做



我尝试过:



这就是我拥有的东西



I have been trying to validate my register form using javascript but i figured by using the: alert('it works") just to see if the js is working of the form but i am getting this error

Notice: undefined index: in gender in c;

which has something to do with the php code. to my js is non functional until that error is fix, tried everything that I can think of and even went searching the net and tried all that I can see but to no avail

can someone help and also it is not inserting into the database, can something tell me what is wrong and why it is not inserting into the database

maybe a third eye will help me what this is not inserting into the database, I am getting all kinds of errors that I cannot see, it give me wrong result when i run it

when i mean wrong result, I mean when a user is registered it, a popup box will popup and tell u welcome to the webpage and then it should redirect the user to the login page an it is not doing that, it instead telling the users that the username already exist ( which I dont have within the code itself) and it either take u back to the index page or back to the register page which not supposed to do

What I have tried:

this is what i have

<pre><?php

		//$register=$_POST['register_user']; 
		if(isset($_POST['Register']))
		{
			
			//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'];
			if(isset($_POST['register']))
			{
				if(isset($_POST['gender'])) 
				{
					$gender = $_POST['gender'];
				}
			}
			else
			{
				$gender = "";
			}
			$address=$_POST['address'];
			$mypwd=$_POST['mypwd'];
			
			include'db_server.php';
			
			//Query the database
			$sql="SELECT * FROM members WHERE username='$username'";
			
			$result= mysqli_query($conn, $sql) or die ("ERROR:" .mysqli_error());
			
			$rowcount=mysqli_num_rows($result);
			
			//checking to see if username is already exist
			if($rowcount >= 1) 
			{
				echo "<script type=\"text/javascript\">
					  alert('Welcome!! Firstname Lastname, you are now a member of the Caribbean Nature Seekers Institute TT(CNSITT)');
					  window.location=\"../login_user.html\";
					   </script>";
					   
				 
			}
			else
			{
				//insert data into table
				
				$sql = "INSERT INTO members
				VALUES('$title', '$firstname','$lastname', '$username', '$email', '$gender', '$address', md5('$mypwd'))";
			
				if(mysqli_query($conn,$sql))
				{
					session_start();
					$_SESSION['user']=$username;					
					header("location:login_user.html");
					mysqli_close($conn);
						
				}
				else
				{
					echo "Error inserting values into database";
				}
				//end of line
				
			}
		}	
		
			
?>





m



m

推荐答案

register =
register=


_POST ['register_user'];
if(isset(
_POST['register_user']; if(isset(


_POST [' 注册']))
{

// 捕获来自表单的变量并存储在php变量中
_POST['Register'])) { //capture the variable from the form and store in php variables


这篇关于如何摆脱或修复此错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆