-2
<?php

if($_POST['submit']=="Sign Up") {

    if(!$_POST['email']) $error.="<br />Please enter your email";
        else if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) $error.="<br />Please enter a valid email adress";

    if(!$_POST['password']) $error.="<br />Please enter your password";
        else {

            if(strlen($_POST['password'])<8) $error.="<br />Please enter a password with at least 8 characters";
            if(!preg_match('`[A-Z]`', $_POST['password'])) $error.="<br />Please include at least one capital letter";
        }

    if($error) echo "There were error(s) in your signup details:".$error;

}

?>
    <form method="post">
        <input type="email" name="e-mail" id="email"/>
        <input type="password" name="password"/>
        <input type="submit" name="submit" value="Sign Up"/>
    </form>

I am getting undefined index notice for the following line:

if($_POST['submit']=="Sign Up") {

What is the meaning of this kind of notices and how do I make it disappear?

Eser Comak
  • 37
  • 8

1 Answers1

0

You have to use isset()

<?php
$value = @$_POST['submit']; 
if(isset($_POST['submit']))//watch here when u  trigger submit button it will find out
if($_POST['submit']=="Sign Up") {

    if(!$_POST['e-mail']) // and here too u have to use e-mail because in ur html code type of input emil name is e-mail
      $error.="<br />Please enter your email";
     else if (!filter_var($_POST['e-mail'], FILTER_VALIDATE_EMAIL)) $error.="<br />Please enter a valid email adress";

    if(!$_POST['password']) $error.="<br />Please enter your password";
        else {

            if(strlen($_POST['password'])<8) $error.="<br />Please enter a password with at least 8 characters";
            if(!preg_match('`[A-Z]`', $_POST['password'])) $error.="<br />Please include at least one capital letter";
        }

    if($error) echo "There were error(s) in your signup details:".$error;

}

?>
    <form method="post">
        <input type="email" name="e-mail" id="email"/>
        <input type="password" name="password"/>
        <input type="submit" name="submit" value="Sign Up"/>
    </form>
Phoenix
  • 467
  • 1
  • 11
  • 23