skip to Main Content
    <body>
    <?php

    include("php/config.php");

     if(isset($_POST['submit'])){

       // $username =$_POST['username'];
       // $PASSWORD =$_POST['PASSWORD'];
      //  $title =$_POST['title'];
      //  $first_name =$_POST['first_name'];
     //   $last_name =$_POST['last_name'];
     //   $gender =$_POST['gender'];
     //   $adress1 =$_POST['adress1'];
     //   $postcode =$_POST['postcode'];
        $email = $_POST['email'];
      //  $telephone =$_POST['telephone'];
      //  $profile_blob =$_POST['profile_blob'];


        $verify_query = mysqli_query($con, " SELECT email FROM users WHERE email ='$email'");

        if(mysqli_num_rows($verify_query) != 0 ){
            echo "<div class='message'>
            <p> This email is used, Try another</p>
            </div> <br>";
            echo "<a href ='javascript:self.history.back()' <button class ='btn'> Go Back </button>"; 
        }

        else{
           // mysqli_query($con,"INSERT INTO     users(username,PASSWORD,title,first_name,last_name,gender,adress1,postcode,email,telephone)Values('$username','$PASSWORD','$title','$first_name','$last_name','$gender','$adress1','$postcode','$email','$telephone')")or die("Error Occured");
       mysqli_query($con,"INSERT INTO users(email)Values('$email')")or die("Error Occured");

          echo "<div class='message'>
        <p> Success</p>
        </div> <br>";
        echo "<a href ='index.php' <button class 'btn'> Go Back </button>";
    }
    


}else{

?>

    <nav class="nav-top">
        <img src="images/Logo.PNG" class="logo"> <!--The logo-->
        <ul>
            <li><a href="Main menu.html">RentmyCaravan.io</a></li> <!--The site title, able to be clicked to go back to the main menu-->
        </ul>
        <img src="images/profile photo.PNG" class="user-pic" onclick="toggleMenu()"> <!--Triggers the script to transition to the submenu-->
        <div class="sub-menu-wrap" id="subMenu"> <!--Surounds the submenu-->
            <div class="sub-menu"> <!--The actual submenu-->
                <div class="user-info"> <!--Anything to do with the user like profile pic and username-->
                    <img src="images/profile photo.PNG">
                    <h2>Dannissoepic</h2>
                </div>
                <hr> <!--A break line-->
                <a href="ListView.html" class="sub-menu-link"> <!--Where it links to-->
                    <img src="images/list.PNG"> <!--The image for it-->
                    <p>List view</p> <!--What the user sees-->
                    <span>></span> <!--Makes it look nicer as a line-->
                </a>
                <a href="AddScreen.html" class="sub-menu-link">
                    <img src="images/+.PNG">
                    <p>Add a caravan</p>
                    <span>></span>
                </a>
                <a href="Edit.html" class="sub-menu-link">
                    <img src="images/empty profile.PNG">
                    <p>Profile</p>
                    <span>></span>
                </a>
                <hr>
                <a href="" class="sub-menu-link">
                    <img src="images/setting.PNG">
                    <p>Settings</p>
                    <span>></span>
                </a>
                <a href="Main menu.html" class="sub-menu-link">
                    <img src="images/signout.PNG">
                    <p>Sign out</p>
                    <span>></span>
                </a>
                <hr>
            </div>
        </div>
    </nav>

    <nav class="nav-site-progress">
        <a href="#">Main Menu</a>
        <a href="#">List View</a>
        <hr>
        <br>
      </nav>

 </header>
        
 
    
    <div class="site">
    <div class="box">
    ----Register new user----
    <br><br>
    Username <br>
    <input type="text" id="username" name="username"><br><br>
    Password <br> 
    <input type="text" id="PASSWORD" name="PASSWORD"><br><br>
    Title <br>
    <input type="text" id="title" name="title"><br><br>
    First Name <br>
    <input type="text" id="first_name" name="first_name"><br><br>
    Last Name <br>
    <input type="text" id="last_name" name="last_name"><br><br>

    Gender
    <input type="text" id="gender" name="gender">
    <input type="checkbox" id="fname6.2" name="fname6.2"><br><br>

    Address <br>
    <input type="text" id="adress1" name="adress1"><br><br>
    Postcode <br>
    <input type="text" id="postcode" name="postcode"><br><br>
    Email <br>
    <input type="email" id="email" name="email"><br><br>
    Phone Number <br>
    <input type="tel" id="telephone" name="telephone"><br><br>
    input profile image <br><br>
    <div style="background-color: #c7c9c9; border: 1px solid black; width: 40%; height: 110px;margin-left: auto; margin-right: auto;">
    <input type="image"id ="fname12" name="fname12" style="border-color: black; width: 70px; height: 50px; text-align: center; background-color: white; " value="+"><br><br>
    </div>
    <br><br>
    <input type="submit" name="submit" value="Register" class="btn-secondary">
    

  
    
    </div>
    </div>
<script>
    let subMenu = document.getElementById("subMenu"); //let submenu be called by the id submenu
    function toggleMenu() //The actual function being called
    {
        subMenu.classList.toggle("open-menu"); //toggle the open menu css class
    }
    </script>



   


    <div>
    <?php } ?>
    </div>

</body>

body of code provided, i have used not (!), to force it, and i know that the code on the other end works. but by trying different things sometimes i get an unidentified key error message for the specific fields for example email but if think that is a result of the page loading the request before the button.

2

Answers


  1. Chosen as BEST ANSWER

    Needed to include tags. My first day on php and clearly i took on to much mumixing it with html.


  2. Make sure you have a form like

    <form method="post" action="yourpage.php">
        Gender
        <input type="text" id="gender" name="gender">
        <input type="checkbox" id="fname6.2" name="fname6.2"><br><br>
    
        Address <br>
        <input type="text" id="adress1" name="adress1"><br><br>
        Postcode <br>
        <input type="text" id="postcode" name="postcode"><br><br>
        Email <br>
        <input type="email" id="email" name="email"><br><br>
        Phone Number <br>
        <input type="tel" id="telephone" name="telephone"><br><br>
        input profile image <br><br>
        <div style="background-color: #c7c9c9; border: 1px solid black; width: 40%; height: 110px;margin-left: auto; margin-right: auto;">
        <input type="image"id ="fname12" name="fname12" style="border-color: black; width: 70px; height: 50px; text-align: center; background-color: white; " value="+"><br><br>
        </div>
        <br><br>
        <input type="submit" name="submit" value="Register" class="btn-secondary">
    </form>
    

    Since your button is now inside a form, by clicking on it, your form will be posted (targeting the action you specified, that action needs to match the end point you want to send the request to, if it’s left blank as action="" then the post will target the current page, which you seem to need in this specific case) and since it has a name of submit, this will be passed and your if should evaluate to true in that case.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search