Skip to content

Instantly share code, notes, and snippets.

Avatar

Amine KOUIS KOUISAmine

View GitHub Profile
View cdn.php
<?php
function getCdnUrls($html)
{
$cdnUrl = "//cdn.mon-domain.com";
$baseUrl = "mon-domain.com";
$patterns = [
// Match sources that are from the www or mobile urls
// We check for the schema as well as protocol relative urls
'~(<(img|script|link)[^>]*)(src|href) *= *(["\'])(https?:)?//(' . preg_quote($baseUrl) . ')~',
View home.php
<!DOCTYPE html>
<?php
require 'connect.php';
?>
<html lang = "eng">
<head>
<meta charset = "UTF-8" />
</head>
<body style="background-color: #DCDCDC">
<center><h2>Création d'un formulaire de connexion en Php avec MySQLi / jQuery</h2></center>
View validator.php
<?php
require_once 'connect.php';
$username = $_POST['username'];
$password = $_POST['password'];
$stmt = $conn->prepare("SELECT * FROM `user` WHERE username = '$username' && `password` = '$password'") or die(mysqli_error());
if($stmt->execute()){
$result = $stmt->get_result();
$num_rows = $result->num_rows;
}
if($num_rows > 0){
View login.js
$(document).ready(function(){
$error = $('<center><label style = "color:#ff0000;">Nom d\'utilisateur ou mot de passe incorrect</label></center>');
$error2 = $('<center><label style = "color:#ff0000;">Utilisateur n\' existe pas!</label></center>');
$success = $('<center><label style = "color:#00ff00;">Connexion réussie!</label></center>');
$loading = $('<center><img src = "loading.gif" height = "5px" width = "100%"/></center>');
$('#login').on('click', function(){
$error.remove();
$error2.remove();
$username = $('#username').val();
$password = $('#password').val();
View style.css
<style>
#content{
background-color: #1E90FF;
width:340px;
height:110px;
margin: 50px auto;
padding:11px;
border-radius:2px;
-webkit-box-shadow:0px 0px 30px 3px #000;
}
View index.html
<!DOCTYPE html>
<?php
require 'connect.php';
?>
<html lang = "eng">
<head>
<meta charset = "UTF-8" />
</head>
<body style="background-color: #DCDCDC">
<center><h2>Création d'un formulaire de connexion en Php avec MySQLi / jQuery</h2></center>
@KOUISAmine
KOUISAmine / connect.php
Last active Feb 10, 2017
Créer un formulaire de connexion en Php avec MySQLi / jQuery
View connect.php
<?php
$conn = new mysqli('localhost', 'root', '', 'connexion');
if($conn->connect_error){
die("Erreur: Impossible de se connecter à la base de données: ". $conn->connect_error);
}
?>
@KOUISAmine
KOUISAmine / connexion.sql
Created Feb 10, 2017
Créer un formulaire de connexion en Php avec MySQLi / jQuery
View connexion.sql
CREATE TABLE IF NOT EXISTS user (
user_id int(11) NOT NULL AUTO_INCREMENT,
username varchar(50) NOT NULL,
password varchar(50) NOT NULL,
PRIMARY KEY (user_id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
@KOUISAmine
KOUISAmine / index.html
Created Feb 8, 2017
Comment créer une liste déroulante dépendante d'une autre liste déroulante avec jQuery/PHP/MYSQL
View index.html
<!DOCTYPE html>
<?php
$conn = new mysqli('localhost', 'root', '', 'db_voiture') or die(mysqli_error());
?>
<html lang = "eng">
<head>
<meta charset = "UTF-8" />
<link rel = "stylesheet" type = "text/css" href = "css/bootstrap.css" />
</head>
<body>
@KOUISAmine
KOUISAmine / image.sql
Created Feb 8, 2017
Simple upload en drag and drop avec MySQLi
View image.sql
--
-- Database: `image`
--
CREATE TABLE `photo` (
`photo_id` int(11) NOT NULL,
`photo_name` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--