Last active
December 13, 2020 11:06
-
-
Save djoudi/e2188e4e0724886a907958dac107da97 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| require_once 'inc/header.php'; | |
| require_once 'inc/config.php'; | |
| require_once 'inc/function.php'; | |
| // Get all Wilaya | |
| /****************************************************/ | |
| $sqlw = "SELECT * FROM wilaya"; | |
| $resw = mysqli_query($connect,$sqlw); | |
| /***************************************************/ | |
| $data['nom'] = (isset($_POST['nom']))?$_POST['nom']:null; | |
| $data['prenom'] = (isset($_POST['prenom']))?$_POST['prenom']:null; | |
| $data['tel'] = (isset($_POST['tel']))?$_POST['tel']:null; | |
| $data['email'] = (isset($_POST['email']))?$_POST['email']:null; | |
| $data['wilaya'] = (isset($_POST['wilaya_id']))?$_POST['wilaya_id']:null; | |
| $add = (isset($_POST['add']))?$_POST['add']:null; | |
| if ($add=='ok') { | |
| if (addClient($data)==1) { | |
| header('Location:listClient.php'); | |
| } | |
| } | |
| ?> | |
| <div class="container mt-5"> | |
| <div class="row"> | |
| <div class="col"> | |
| <form action="" method="post"> | |
| <div class="form-row"> | |
| <div class="form-group col-md-6"> | |
| <input type="text" name="nom" class="form-control" id="nom" placeholder="Nom"> | |
| </div> | |
| <div class="form-group col-md-6"> | |
| <input type="text" name="prenom" class="form-control" id="prenom" placeholder="Prénom"> | |
| </div> | |
| </div> | |
| <div class="form-group"> | |
| <input type="email" name="email" class="form-control" id="email" placeholder="Email"> | |
| </div> | |
| <div class="form-group"> | |
| <input type="tel" name="tel" class="form-control" id="tel" placeholder="Tel Number"> | |
| </div> | |
| <div class="form-group"> | |
| <select name="wilaya_id" > | |
| <?php | |
| while ($data = mysqli_fetch_array($resw)): | |
| ?> | |
| <option value="<?=$data['id'] ?>"><?=$data['nom'] ?></option> | |
| <?php endwhile; ?> | |
| </select> | |
| </div> | |
| <input type="hidden" name="add" value="ok"> | |
| <button type="submit" class="btn btn-primary btn-lg">Add Client</button> | |
| </form> | |
| </div> | |
| </div> | |
| </div> | |
| <?php | |
| require_once 'inc/footer.php'; | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| require_once 'inc/header.php'; | |
| require_once 'inc/config.php'; | |
| // get data from Form | |
| $nom = (isset($_POST['nom']))?$_POST['nom']:null; | |
| $prix = (isset($_POST['prix']))?$_POST['prix']:null; | |
| $add = (isset($_POST['add']))?$_POST['add']:null; | |
| if ($add=='ok') : | |
| // Upload Files | |
| $filename = $_FILES['photo']['name']; | |
| $size = $_FILES['photo']['size']; | |
| $tmp = $_FILES['photo']['tmp_name']; | |
| $path = 'upload/'; | |
| // get Extention | |
| $ext = explode('.', $filename); | |
| $ext = end($ext); | |
| $allowed = ['png','jpg','jpeg','svg']; | |
| $dist = time().'.'.$ext; | |
| //echo $dist; | |
| /*if (in_array($ext,$allowed)) { | |
| # code... | |
| } | |
| */ | |
| move_uploaded_file($tmp,$path.$dist); | |
| // insert Data to database | |
| $sql = "INSERT INTO products(id,nom,prix,photo) VALUES(NULL,'$nom',$prix,'$dist')"; | |
| $set = mysqli_query($connect,$sql) or die(mysqli_error($connect)); | |
| if ($set) { | |
| header('Location:listProduct.php'); | |
| } | |
| endif; | |
| ?> | |
| <div class="container mt-5 p-5"> | |
| <div class="row"> | |
| <div class="col"> | |
| <form action="" method="post" enctype="multipart/form-data"> | |
| <div class="form-row"> | |
| <div class="form-group col-md-6"> | |
| <input type="text" name="nom" class="form-control" id="nom" placeholder="Nom"> | |
| </div> | |
| <div class="form-group col-md-6"> | |
| <input type="text" name="prix" class="form-control" id="prix" placeholder="Prix"> | |
| </div> | |
| </div> | |
| <div class="form-group"> | |
| <input type="file" name="photo" class="form-control" id="photo" placeholder="Photo"> | |
| </div> | |
| <input type="hidden" name="add" value="ok"> | |
| <button type="submit" class="btn btn-primary btn-lg">Add Product</button> | |
| </form> | |
| </div> | |
| </div> | |
| </div> | |
| <?php | |
| require_once 'inc/footer.php'; | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $host = 'localhost'; | |
| $user = 'root'; | |
| $password = ''; | |
| $dbname = 'webdbv2'; | |
| $connect = @mysqli_connect($host,$user,$password,$dbname) or die(mysqli_connect_error($connect)); | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| require_once 'inc/config.php'; | |
| $cid = $_GET['u']; | |
| $sql = "DELETE FROM clients WHERE id = $cid"; | |
| $res = mysqli_query($connect,$sql) or die(mysqli_error($connect)); | |
| if ($res) { | |
| header('Location:listClient.php'); | |
| } | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| require_once 'inc/header.php'; | |
| require_once 'inc/config.php'; | |
| //get Data | |
| $cid = $_GET['m']; | |
| $sqlm = "SELECT * FROM clients WHERE id = $cid limit 1"; | |
| $resm = mysqli_query($connect,$sqlm) or die(mysqli_error($connect)); | |
| $num = mysqli_num_rows($resm); | |
| if ($num ==1) { | |
| $data = mysqli_fetch_array($resm,MYSQLI_ASSOC); | |
| } | |
| // update Data | |
| $nom = (isset($_POST['nom']))?$_POST['nom']:null; | |
| $prenom = (isset($_POST['prenom']))?$_POST['prenom']:null; | |
| $tel = (isset($_POST['tel']))?$_POST['tel']:null; | |
| $email = (isset($_POST['email']))?$_POST['email']:null; | |
| $id = (isset($_POST['id']))?$_POST['id']:null; | |
| $edit = (isset($_POST['edit']))?$_POST['edit']:null; | |
| if ($edit=='ok') { | |
| $sqlU = "UPDATE clients SET nom='$nom',prenom='$prenom',tel='$tel',email='$email' WHERE id= $id"; | |
| $set = mysqli_query($connect,$sqlU) or die(mysqli_error($connect)); | |
| if ($set) { | |
| header('Location:listClient.php'); | |
| } | |
| } | |
| ?> | |
| <div class="container mt-5"> | |
| <div class="row"> | |
| <div class="col"> | |
| <form action="" method="post"> | |
| <div class="form-row"> | |
| <div class="form-group col-md-6"> | |
| <input type="text" name="nom" class="form-control" placeholder="Nom" value="<?=$data['nom'] ?>"> | |
| </div> | |
| <div class="form-group col-md-6"> | |
| <input type="text" name="prenom" class="form-control" placeholder="Prénom" value="<?=$data['prenom'] ?>"> | |
| </div> | |
| </div> | |
| <div class="form-group"> | |
| <input type="email" name="email" class="form-control" value="<?=$data['email'] ?>" placeholder="Email"> | |
| </div> | |
| <div class="form-group"> | |
| <input type="tel" name="tel" class="form-control" value="<?=$data['tel'] ?>" placeholder="Tel Number"> | |
| </div> | |
| <input type="hidden" name="id" value="<?=$data['id'] ?>"> | |
| <input type="hidden" name="edit" value="ok"> | |
| <button type="submit" class="btn btn-primary btn-lg">Edit Client</button> | |
| </form> | |
| </div> | |
| </div> | |
| </div> | |
| <?php | |
| require_once 'inc/footer.php'; | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function addClient($data) | |
| { | |
| global $connect; | |
| $sql = "INSERT INTO clients(id,nom,prenom,email,tel,wilaya_id) VALUES(NULL,'{$data['nom']}','{$data['prenom']}','{$data['email']}','{$data['tel']}',{$data['wilaya']})"; | |
| $set = mysqli_query($connect,$sql) or die(mysqli_error($connect)); | |
| if ($set) return 1; | |
| else return 0; | |
| } | |
| function editClient($data) | |
| { | |
| /// | |
| } | |
| function deleteClient($data) | |
| { | |
| /// | |
| } | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| require_once 'inc/header.php'; | |
| require_once 'inc/config.php'; | |
| $sql = 'SELECT * FROM clients'; | |
| $res = mysqli_query($connect,$sql) or die(mysqli_error($connect)); | |
| $num = mysqli_num_rows($res); | |
| ?> | |
| <div class="container mt-5"> | |
| <div class="row"> | |
| <div class="col"> | |
| <div class="table-responsive"> | |
| <table class="table table-light"> | |
| <caption>List of Client</caption> | |
| <thead class="thead-light"> | |
| <tr> | |
| <th scope="col">Nom</th> | |
| <th scope="col">Prenom</th> | |
| <th scope="col">E-Mail</th> | |
| <th scope="col">Action</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <?php | |
| while ($data = mysqli_fetch_array($res)): | |
| ?> | |
| <tr> | |
| <th scope="row"><?=$data['nom'] ?></th> | |
| <td><?=$data['prenom'] ?></td> | |
| <td><?=$data['email'] ?></td> | |
| <td> | |
| <a href="deleteClient.php?u=<?=$data['id'] ?>" class="btn btn-danger"> | |
| <i class="fa fa-trash" aria-hidden="true"></i> | |
| </a> | |
| <a href="editClient.php?m=<?=$data['id'] ?>" class="btn btn-info"> | |
| <i class="fa fa-pencil-square-o" aria-hidden="true"></i> | |
| </a> | |
| </td> | |
| </tr> | |
| <?php endwhile; ?> | |
| </tbody> | |
| </table> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <?php | |
| require_once 'inc/footer.php'; | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| require_once 'inc/header.php'; | |
| require_once 'inc/config.php'; | |
| $sql = 'SELECT * FROM products'; | |
| $res = mysqli_query($connect,$sql) or die(mysqli_error($connect)); | |
| $num = mysqli_num_rows($res); | |
| ?> | |
| <div class="container mt-5"> | |
| <div class="row"> | |
| <?php | |
| while ($data = mysqli_fetch_array($res)): | |
| ?> | |
| <div class="col"> | |
| <div class="card"> | |
| <img src="upload/<?=$data['photo'] ?>" class="card-img-top img-fluid" style="width: 16%" alt="..."> | |
| <div class="card-body"> | |
| <h5 class="card-title"><?=$data['nom'] ?></h5> | |
| <a href="#" class="btn btn-primary"><?=$data['prix'] ?></a> | |
| </div> | |
| </div> | |
| </div> | |
| <?php endwhile; ?> | |
| </div> | |
| </div> | |
| <?php | |
| require_once 'inc/footer.php'; | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment