Giter VIP home page Giter VIP logo

parismollo / equipo Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 336 KB

Join a community of creative minds! Our social media platform, built with PHP, CSS, HTML, and SQL, lets you share your latest projects with like-minded people and connect with potential collaborators based on shared interests and skills. Collaborate, innovate, and create something amazing today!

PHP 87.59% CSS 12.41%
authetication database design php sql

equipo's Introduction

  • 👋 Hi, I’m @parismollo
  • 👀 I’m interested in smart city technologies
  • 🌱 I’m currently working on Mia Labs
  • 📫 How to reach me: [email protected]

While the majority of my projects are private, I can provide you access to view them. Simply send me a message at [email protected], and I will be happy to grant you access.

equipo's People

Contributors

mojigot7 avatar parismollo avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

equipo's Issues

Main file (database)

Create main file to set MySQL tables and user admin accounts (login and password)

  • main file (php) to generate database table (tous)
  • create admin account
  • create tags

Redirection in try again link

function save_user($user_input){
    global $server, $user, $password, $database;
    // 1. connection 2.generate insert query 3. insert user and handle return.
    $connection = connect_to_db($server, $user, $password, $database);
    if(isset($connection)){
      $query = insert_user_query($user_input, $connection);
      $res = mysqli_query($connection, $query);
      if(!$res){
        $error = mysqli_error($connection);
        display_error_page($error, "signup.php"); // or here
      }else {
        echo "It works!"; // here is the error 
      }
    }else{
      display_error_page("Connection failed", "signup.php");
    }
  }
?>

Warning: Undefined array key "pseudo" in ....

Error output

Warning: Undefined array key "pseudo" in C:\Users\paris\XAMPP\htdocs\Projet_universite\Equipo2.0\database\user.php on line 45

Replicate error

  1. Log with a existant account
  2. Once you are in the welcome page, change the get param on the url to ?action=login. It will output the error showed above.

Expected behavior

  • If user is logged, and if he tries to access log in page he will be redirected to his welcome page. Need to check if there is a session and if there is, the "switch" from the signup.php need to be ready for every case.

Admin

  • write function that allow admins to delete projects accounts

Forms Front-End

  • Sign up form
  • Login form
  • errors in form
  • something went wrong
  • duplicate entry
  • Disconnected

Create Project

  • User can create project from profile page (later will in home page)

Login

  • Handle login form data
  • login SQL (connection, query, find user, handle error)
  • Start session
  • logout

Page d'accueil : Home Page

Details at image

  • home page (html and css) @Mojigot7
  • user page (other user page)
  • project page (other user page)
  • If no interests show button to add interests
  • query - select projects that have the same you add in update profile @Mojigot7

Refactor Login & Sign up

Refactor login and sign in cases in switch

  • Refactor signup.php and login.php
  • check form validations
  • check database connection and query generation
  • saving user
  • error handling
  • Session and session check in all pages
  • logout

Currrent state

  • bit messy
  • not very modular
  • too much code
    // signup.php
  .........
  if(isset($_GET["action"])){
    $param = $_GET["action"];
    switch ($param) {
      case 'signup':
        $errors = validate_data($_POST, $errors);
        if (empty($errors)){
          form_validation($_POST);
          if(save_user($_POST)){
            login_form($errors, "");
          }  
        }else{
          signup_form($errors);
        }
        break;
      case 'login':
        $errors = validate_data2($_POST, $errors);
        if (empty($errors)){
          form_validation($_POST);
          if(login_user($_POST)){
            header('Location: signup.php?action=welcome');
          } else{
            login_form($errors, $wrong);
          }
        } else{
          login_form($errors,"");
        }
        break;
      case 'signin':
        login_form($errors,"");
        break;  
      case 'welcome':
        echo "Welcome ".$_SESSION['pseudo'];
        break;    
      default:
        signup_form($errors); // display fonctions
        break;
    }
  }else {
    signup_form($errors);
  }
     .......

Refactoring Proposal

  • easier to read
  • modular
  • easy to debbug

The following is an example based on the code from the IO2 homework's that I did.
//signup.php

if (isset($_GET["action"])){
    $param = $_GET['action'];
    switch ($param) {
      case 'validate_data':
        $bool = verify_form_data($_POST);
        redirect_user($bool, $_POST);
        break;
      default:
        display_form();
    }
  }else {
    display_form();
  }

// login.php

<?php
  session_start();
  require_once("display_functions.php"); require_once("handle_input_data.php");
  if (isset($_GET["action"])){
    $param = $_GET["action"];
    switch ($param) {
      case 'login':
        if (handle_login_data($_POST)){
          redirect_login($_POST);
        }else {
          echo "Missing fields...<br>";
          echo "<a href=\"login.php\">Try again</a>";
        }
        break;
      case 'reset':
        $_SESSION = array();
        session_destroy();
        header("Location: login.php");
        break;
      default:
        display_login();
        break;
    }
  }else{
    if (isset($_SESSION["user"])){
      echo "Yeah what's up ", $_SESSION["user"], "?";
      echo "<br><a href=\"login.php?action=reset\">Reset Session</a>";
    }else {
      display_login();
    }
  }
?>

Profile page

  • Show user interests (tags) in profile page
  • on update profile - allow user to follow "tags"

Profile CSS

  • update profile CSS
  • Button to create project

home page

  • mettre liens dans navbar
  • mettre lien pour creer projet
  • mettre lien pour ajouter interet

Post : Project

  • Show project collaborators
  • Show project tags
  • display general form errors
  • validate user data
  • cant' create duplicate project error display
  • allow user to delete project - fix css button
  • add upvotes
  • add collaborator method

Login

Login workflow

  • login form
  • error handling
  • redirection
  • session creation

admin bug

if you run twice the script the app crash
possible solution: always drop the tables and create it once the script is called

  • fix bug above
  • fix link "go back" in case of error

Sign in form

CSS + Figma form design and implementation

  • Sign up form
  • Login form
  • Error displays
  • Success displays

Improvements

Review

  • Form
  • Sign up
  • Database
  • Login
  • Validation

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.