Hi, I am a newbie in developing a website. i have tried to connect using mysqli conncetion
    Here is my simple code.

    // db.php code
    _______________________

    <?php

    //$con = mysqli_connect("localhost","root","","bakery");
    $db = mysqli_connect('localhost', 'root', '', 'bakery');

    // Check connection
    if (mysqli_connect_errno())
      {
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
      }

    ?>

-------------------------------------------------------------------------------
**//Sign up form in index.php**

<?php
                require('db.php');
                // If form submitted, insert values into the database.
                if (isset($_REQUEST['firstname'])){
                    $firstname = stripslashes($_REQUEST['firstname']); // removes backslashes
                    $firstname = mysqli_real_escape_string($con,$firstname); //escapes special characters in a string
                    $lastname = stripslashes($_REQUEST['lastname']); // removes backslashes
                    $lastname = mysqli_real_escape_string($con,$lastname); //escapes special characters in a string
                    $username = stripslashes($_REQUEST['username']); // removes backslashes
                    $username = mysqli_real_escape_string($con,$username); //escapes special characters in a string
                    $phonenumber = stripslashes($_REQUEST['phonenumber']); // removes backslashes
                    $phonenumber = mysqli_real_escape_string($con,$phonenumber); //escapes special characters in a string
                    $email = stripslashes($_REQUEST['email']);
                    $email = mysqli_real_escape_string($con,$email);
                    $password = stripslashes($_REQUEST['password']);
                    $password = mysqli_real_escape_string($con,$password);
                    $trn_date = date("Y-m-d H:i:s");

                            $query = "INSERT into `login` (firstname, lastname, username, phonenumber, email, password, trn_date) VALUES ('$firstname', '$lastname', '$username', '$phonenumber', '$email', '".md5($password)."', '$trn_date')";
                    $result = mysqli_query($con,$query);
                    if($result){
                            //echo "<div class='form'><h3>You are registered successfully.</h3><br/>Click here to <a href='login.php'>Login</a></div>";
                        header( 'Location: content.php' );
                    }
                }else{}
                ?>

   ----------------------------------------------------------
          **  // sign in form in index.php**

             <?php
                require('db.php');
                session_start();

                if($_POST['username'] == $username && $_POST['password'] == $password)
                    header( 'Location: content.php' );
                ?> 

Help us to help you. What error are you getting or what behavior are you seenig that you don't expect?

the button to submit the form seems not working. when i click the button to submit the form, it shows no response.

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.