Greetings guys, can you help me about this error? the error say's

Notice: Undefined index: username in C:\xampp\htdocs\email_verify\index.php on line 23

Notice: Undefined index: password in C:\xampp\htdocs\email_verify\index.php on line 25

<?php 
    session_start();
    if(isset($_SESSION['error']))
    {
        echo '<p>'.$_SESSION['error']['username'].'</p>';
        echo '<p>'.$_SESSION['error']['email'].'</p>';
        echo '<p>'.$_SESSION['error']['password'].'</p>';
        unset($_SESSION['error']);
    }
?>

Thanks in advance.

Recommended Answers

All 2 Replies

Paste your code regarding the username and password.
Where do you assign the password and username to your session ?

<?php
    session_start();
    include('configdb.php');

    if(isset($_POST['submit']))
    {
        if($_POST['username'] == '')
        {
            $_SESSION['error']['username'] = "User Name is required.";
        }
        if($_POST['email'] == '')
        {
            $_SESSION['error']['email'] = "E-mail is required.";
        }
            else
            {
                if(preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/", $_POST['email']))
                {
                    $email= $_POST['email'];
                    $sql1 = "SELECT * FROM user WHERE email = '$email'";
                    $result1 = mysqli_query($mysqli,$sql1) or die(mysqli_error());
                    if (mysqli_num_rows($result1) > 0) {
                        $_SESSION['error']['email'] = "This Email is already used.";
                    }
                }
                else
                {
                $_SESSION['error']['email'] = "Your email is not valid.";
                }
            }
        if($_POST['password'] == '')
        {
            $_SESSION['error']['password'] = "Password is required.";
        }

        if(isset($_SESSION['error']))
        {
            header("Location: index.php");
            exit;
        }
        else
        {
            $username = $_POST['username'];
            $email = $_POST['email'];
            $password = $_POST['password'];
            $com_code = md5(uniqid(rand()));

            $sql2 = "INSERT INTO user (username, email, password, com_code) VALUES ('$username', '$email', '$password', '$com_code')";
            $result2 = mysqli_query($mysqli,$sql2) or die(mysqli_error());

            if($result2)
            {
                $to = $email;
                $subject = "Confirmation from WebInone.net to $username";
                $header = "WebInOne: Confirmation from WebInone.net";
                $message = "Please click the link below to verify and activate your account. \r\n";
                $header .= "http://www.webinone.net/confirm.php?passkey=$com_code";

                $sentmail_From = mail($to,$subject,$message,$header);

                if($sentmail_From){
                    echo "Your Confirmation link Has Been Sent To Your Email Address.";
                }
                else {
                    echo "Cannot send Confirmation link to your e-mail address";
                }
            }
        }
    }
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.