Giter VIP home page Giter VIP logo

ourfirstproject's Introduction

HTML5 CSS3 JavaScript PHP

📝 Project Ninja Guerreiro

📜This repository consists of the source code of a form made in HTML/CSS using PHP as its back-end together with the MySQL Database.

Table of Contents

Introduction

adadada

Registering users with HTML and PHP

Typically, a web page has a landing page, but we decided to begin with the sign-up system since it will help determine a database setup.

This system is composed of four inputs from HTML. The connection with the database will be made using PHP.

Using HTML, we can define the building blocks of the signup system. It is worth noting that this can be done using Bootstrap, but it is always good to practice the basics of HTML.

To simplify the process, only HTML will be used for the landing page instead of extensive CSS coding. However, it is still important to consider certain factors to avoid any potential issues during the development process.

Typically, a web page has a landing page, but we decided to begin with the sign-up system since it will help determine a database setup.

This system is composed of four inputs from HTML. The connection with the database will be made using PHP.

Using HTML, we can define the building blocks of the signup system. It is worth noting that this can be done using Bootstrap, but it is always good to practice the basics of HTML.

HTML

HTML SIGNUP

HTML

<div class="sign" id="signup">
	<!-- It's important to mention that one the attribute "name=''" is used on the PHP file -->
	<form method="POST" action="exemple.php"> <!-- The method POST creates a request for the action -->
		<input type="text" id="username" class="user-name" name="username" placeholder="username">
		<input type="email" id="email" class="e-mail" name="email" placeholder="email">
		<input type="password" id="password" class="pass-word" name="password" placeholder="password">
		<input type="password" id="corfirmpassword" class="confirm_password" name="confirm-password" placeholder="confirm password">
		<button id="sign-button">Register!</button> <!-- Send the form -->
	</form>
</div>

Notice that each ID or CLASS will not be used yet, so you do not have to follow or copy this code. Try to build your example. Furthermore, pay attention to the name attribute definition. Choose a name that matches the input action, as it will make the next part easier to understand. Now, let's advantage and also build the login code.


HTML LOGIN

Using the same system that will be made in PHP, we can also start building the login code in HTML. Follow the code, and pay attention to the name attribute.

HTML

<div class="login" id="login">
	<form method="POST" action="example.php">

		<input type="email" id="email" class="e-mail" name="email2" placeholder="email">
		<!-- For those who didn't notice I changed the name attribute name-->

		<input type="password" id="password" class="pass-word" name="password2" placeholder="password"><!--here as well-->

		<button id="log-button">logar</button><!--You actually do have to change or specify if a button id is related to the log in or sign-up, you can choose a same id for both-->

	</form>
</div>

Finally, let's dive into PHP, starting with the connection.


PHP

Com os inputs criados podemos fazer nossa primeira requisição no PHP, mas antes de tudo isso temos que fazer a conexão com o Banco de Dados.

Primeiro temos que criar um novo arquivo .php, contendo as seguintes informações, DB_HOST, DB_USER, DB_PASSWORD e DB_DATABASE.

Segue exemplo:

<?php

// Classe criada para declarar as variáveis privadas ou públicas.
class DB_Connection{
    private $host = "******"; // DB_HOST
    private $user = "******"; // DB_USER
    private $pswd = "******"; // DB_PASSWORD
    private $db = "******"; // DB_DATABASE

// Quando criada a classe, criamos também a função a ser executada.
    public function __construct(){  
				// Nesta linha criamos a variável $conn, para se referir a instância criada apartir do new, outra coisa a se observar é o $this que se trata de uma pseudo-variável que se refere a um objeto.
        $conn = new mysqli($this->host, $this->user, $this->pswd, $this->db);

				// Aqui ocorre uma condição, SE $conn for igual a connect_error, ou ocorrer um erro do mesmo, ele mata o código("die()") e apresenta o erro.
        if($conn->connect_error){
            die("Erro na conexão!");
        }
				// Caso o código passe por todas as etapas sem apresentar erro, ele escreve na tela a mensagem "Conexão Estabelecida!".
        echo "Conexão Estabelecida!";
    }
}

?> 

..

ourfirstproject's People

Contributors

lmardark avatar pedro-miguel20 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.