Jump to content

error on line 12&13


dean012

Recommended Posts

Notice: Undefined index: username in C:\Users\User\l\htdocs\registerarrow-10x10.png.php on line 12

Notice: Undefined index: passwordarrow-10x10.png in C:\Users\User\l\htdocs\register.php on line 13

<html>
<body>

<?php
$connect=mysql_connect("localhost","root","");
$db_selected = mysql_select_db("users", $connect); 


if(isset($_POST['register'])){


$username= $_POST['username'];
$password= $_POST['password'];
	
	if(!$username || !$password){
	echo "One of the fields are empty";
	}else{
	$find_multiple=" SELECT username FROM registerion WHERE Username='$username' ";
	$run_multiple = mysql_query($find_multiple) or die (mysql_error());
	$num_multiple= mysql_num_rows($run_multiple);
	
	if($num_multiple < 1){
	$password= md5($password);
		
	mysql_query( "INSERT INTO `register` (`username`, `password`) VALUES ('".$username."', '".$password."')" ) or die(mysql_error());
	echo "You have succesfully registered!";
	
	}else{
		echo "That username has already beed used" ;
} 
    
     } # endelse: empty password or username
} # endif: registered
?>	
<head>
<h1>Register</h1>
<form action='' method='post'>
username: <input type='text' name='username'/></br>
password: <input type='password' name='password'/></br>
<input type='submit' value='Register'name='register'/>

</form> 
</body>
</html>

Link to comment
Share on other sites

This probably isn't causing the issue, but the <head> and <body> tags are mixed up.

 

Have you tried breaking the code down to the essentials to get the form working? For example, does the following work:

<?php
//REPORT ALL PHP ERRORS
error_reporting(E_ALL);
ini_set('display_errors', 1);
 
 
if(isset($_POST['register'])){
     printf('<pre>%s</pre>', print_r($_POST, true));
}
?>
<html>
<head>
<title>Page Title Here</title>
</head>
<body>
<h1>Register</h1>
<form action='' method='post'>
username: <input type='text' name='username'/></br>
password: <input type='password' name='password'/></br>
<input type='submit' value='Register'name='register'/>
</form> 
</body>
</html>

If so, you can slowly add the other features until everything works.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.