0

Hi!
Good day to all.. .
can somebody help me with my code because when it comes to browser it always say this thing.

Notice: Undefined index: submit in C:\wamp\www\pm_login\register.php on line 3

Notice: Undefined index: fullname in C:\wamp\www\pm_login\register.php on line 5

Notice: Undefined index: username in C:\wamp\www\pm_login\register.php on line 6

Notice: Undefined index: password in C:\wamp\www\pm_login\register.php on line 7

Notice: Undefined index: repeatpassword in C:\wamp\www\pm_login\register.php on line 8

<?php
echo "<h1>Register Now!</h1></br>";
$submit = $_POST["submit"];

$fullname = $_POST["fullname"];
$username = $_POST["username"];
$password = md5($_POST["password"]);
$repeatpassword = md5($_POST["repeatpassword"]);


if ($submit)
{
	echo "$username/$password/$repeatpassword/$fullname";
	
}
?>

can you help me here guys..

thanks alot.. .

have a nice day.

3
Contributors
5
Replies
8
Views
6 Years
Discussion Span
Last Post by pritaeas
0

If the form is not submitted then the POST values are not set yet, hence the notice. Try:

<?php
  echo "<h1>Register Now!</h1></br>";
  $submit = isset($_POST["submit"]) ? true : false;
 
  if ($submit)
  {
    $fullname = $_POST["fullname"];
    $username = $_POST["username"];
    $password = md5($_POST["password"]);
    $repeatpassword = md5($_POST["repeatpassword"]);

    echo "$username/$password/$repeatpassword/$fullname";
  }
?>
0

@Shanti_Chepuru

Heres my code.. .

<?php
echo "<h1>Register Now!</h1></br>";
$submit = $_POST["submit"];

$fullname = strip_tags ($_POST["fullname"]);
$username = strip_tags($_POST["username"]);
$password = strip_tags($_POST["password"]);
$repeatpassword = strip_tags($_POST["repeatpassword"]);
$date = date("Y-m-d");

if ($submit)
{
	//check for existence
	if ($fullname&&$username&&$password&&$repeatpassword)
	{
		$password = md5 ($password);
		$repeatpassword = md5 ($repeatpassword);
		if ($password==$repeatpassword)
		{
		
			//check lenght of username and fullname
			if(strlen ($username)>30||strlen($fullname)>30)
			{
				echo "Max limit for username/fullname are 30 characters only";
			}
		}
		else
		{
			if (strlen ($password)>30||strlen($password)<6)
			{
				echo "Password must be between 6 and 25 characters!";
			}
			else
			{
				//register user
				echo "success!";
			}
		}
		}
	}
	else
	{
		echo "Please fill in <b>all</b> fields!</br>";
	}
	


?>

<html>
<p>
<form action="register.php" method="POST">
<table>
<tr>
<td>
Your full name:
</td>
<td>
<input type="text" name="fullname">
</td>
</tr>

<tr>
<td>
Username:
</td>
<td>
<input type="text" name="username">
</td>
</tr>
<tr>
<td>
Password:
</td>
<td>
<input type="text" name="password">
</td>
</tr>
<tr>
<td>
Repeat Password:
</td>
<td>
<input type="text" name="repeatpassword">
</td>
</tr>
<tr>
<td>

</table>
<input type="submit" name="submit" value="Register">
</form>

</html>

im using POST.

can you help me here!

Thanks alot..

0

your code is perfectly fine...
As per priteas insert these lines:

$submit = isset($_POST["submit"]) ? true : false;
if ($submit)
{
// your code
}

or try to print this:

if($_SERVER['REQUEST_METHOD'] == "POST")
{
print_r($_POST);
}

try once and post the error what exactly you got.

Edited by Shanti C: n/a

0
$password = md5 ($password);
...
if (strlen ($password)>30||strlen($password)<6)

Your if statement will always fail, as md5 returns a 32 character string.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.