hi

am doing this assignment in web develpment. have been trying to run it but for some reason it is not working.

maybe a third eye will hope

here is the code

<?php

        error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

        if(isset($_POST['register_user']))
        {
            //capture the variable from the form and store in php variables

            $title=$_POST['title'];
            $fullname=$_POST['fullname'];
            $lastname=$_POST['lastname'];
            $screenname=$_POST['screenname'];
            $email=$_POST['email'];
            $gender=$_POST['gender'];
            $address=$_POST['address'];
            $mypwd=$_POST['mypwd'];

            //connecting to the server

            include'db_server.php';

            $conn = mysqli_connect($db_host,$db_username,$db_password) or die (mysqli_connect_error());

            //select the database you want to query

            mysqli_select_db($conn, 'national_wonders') or die (mysqli_error($conn));
            $sql = "SELECT * FROM members WHERE screenname='$screenname'";
            $result = mysqli_query($conn, $sql) or die ("ERROR:" .mysqli_error());
            $rowcount = mysqli_num_rows($result);

            if($rowcount >= 1)
            {
                echo"<script type=\"text/javascript\">
                    alert('Username already exits!!');
                    window.location=\"../php/popup.php\";
                    </script>";
            }
            else
            {
                //insert data into table

                $sql = "INSERT INTO members
                VALUES('$title', '$fullname', '$lastname', '$screenname', '$address', '$email', '$gender',  'md5('$mypwd))";

                if(mysqli_query($conn,$sql))
                {
                    echo"<script type=\"text/javascript\">
                    alert(Welcome);
                    window.location=\"login.php\";
                    </script>";
                }
                else
                {
                    echo "Error inserting values into database";
                }

            }

        }   

?>

What error message are you getting? What isn't working as intended?

that is the problem dani, am not getting any kind of errors that i can show, all it say error inserting data in database, so i dont know if it is some error within the code and I am not seeing it. and i run it again and i am now seeing this error,

the error is the variable $conn,

Notice: Undefined variable: conn in C:\wamp64\www\Taylor_Luana_ITEC244_Assignment\php\register_user.php on line 35

I use the echo, to echo out the error and that is how that error come up

Is the question still relevant?

I got it fix thanks

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.