0

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.

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by Jake.20
0

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

0
<?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";
                }
            }
        }
    }
?>
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.