I would like to display an alert after sending an email as in this portfolio: https://www.mathieu-crevoulin.com/ after when you send mail you can see this alert : E-mail envoyé avec succès !
Merci pour votre message !
Une réponse vous sera apportée dans les plus brefs délais.
contact.php
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
if(isset($_POST["send"])){
$body = $_POST['message'];
$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'mymail#mail.com';
$mail->Password = 'psw';
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption
$mail->Port = 465;
$mail->setFrom('mymail#mail.com');
$mail->addAddress($_POST["email"]);
$mail->isHTML(true);
$mail->Subject = 'Projet web';
$mail->Body = "Message:" . $body . "<br>Phone number: " . $phone . "<br>Name: " . $name . "<br>Mail: " . $email;
$mail->send();
header("Location: http://127.0.0.1/test2/confirmmail.html#scrollspyHeading7");
}
index.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons#1.9.1/font/bootstrap-icons.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.2/animate.min.css" integrity="sha512-doJrC/ocU8VGVRx3O9981+2aYUn3fuWVWvqLi1U+tA2MWVzsw+NVKq1PrENF03M+TYBP92PnYUlXFH1ZW0FpLw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="https://unpkg.com/aos#next/dist/aos.css" />
<script src="https://kit.fontawesome.com/1aca141b14.js" crossorigin="anonymous"></script>
<title>Portfolio</title>
</head>
<body>
<style>
#success-message, #error-message
{
display: none;
}
</style>
<nav class="navbar navbar-expand-lg fixed-top navbar-custom" style="padding: 1%;">
<div class="container">
<a class="navbar-brand" href="#">
<img src="logo.png" alt="Avatar Logo" style="width:40px;" class="rounded-pill">
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-center" id="navbarNav">
<ul class="navbar-nav justify-content-center">
<li class="nav-item">
<a class="nav-link" href="#scrollspyHeading1">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#scrollspyHeading2">Services</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#scrollspyHeading3">Compétences</a>
</li>
<!-- <li class="nav-item">
<a class="nav-link" href="#scrollspyHeading4">Portfolio</a>
</li> -->
<li class="nav-item">
<a class="nav-link" href="#scrollspyHeading6">À Propos</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#scrollspyHeading7">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- images/114-1144561_copyright-free-images-on-desk-with-laptop-and.jpg
images/269-2698560_high-resolution-laptop-desktop-wallpaper-hd.jpg
images/10705380.jpg -->
<div data-bs-spy="scroll" data-bs-target="#navbar-example2" data-bs-root-margin="0px 0px -40%" data-bs-smooth-scroll="true" class="scrollspy-example bg-light rounded-2" tabindex="0">
<div id="carouselExampleInterval" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-inner" id="scrollspyHeading1">
<div class="carousel-item active " data-bs-interval="3000">
<img src="images/888777555.jpeg" class="d-block w-100" alt="...">
<div class="carousel-caption d-flex flex-column justify-content-center h-100" style="top: 0">
<h2 class="in-left">Développeur indépendant</h2>
<p class="in-left">SAVINOV Denis</p>
</div>
</div>
</div>
<div class="col-10 footertext" data-aos="fade-right">
<h5 class="text-end"><strong>Intégration Web</strong></h5>
<p class="text-end grisclaire">Des intégrations (X)HTML / CSS respectueuses des
standards du Web.
</p>
</div>
<div class="col-2" data-aos="fade-right">
<i class="fa-solid fa-code fa-2xl"></i>
</div>
<div class="col-10 footertext" data-aos="fade-right">
<h5 class="text-end"><strong>Développements spécifiques</strong></h5>
<p class="text-end grisclaire">Des outils adaptés à votre coeur de métier,
applications & solutions personnalisées.</p>
</div>
<div class="col-2" data-aos="fade-right">
<i class="fa-solid fa-wrench fa-2xl"></i>
</div>
<div class="col-10 footertext" data-aos="fade-right">
<h5 class="text-end"><strong>Référencement naturel</strong></h5>
<p class="text-end grisclaire">Affichage sémantique des informations,
des pages propres pour un référencement optimal.</p>
</div>
<div class="col-2" data-aos="fade-right">
<i class="img-fluid material-icons" style="width: 100%;"><img class="img-fluid w-100" src="images/5902216.png" alt="" style="width: 100%;"></i>
</div>
</div>
</div>
<div class="col-md-4 mb-3 mb-md-0 row align-items-center">
<div class="row align-items-center" data-aos="fade-up">
<div class="col">
<img src="images/index1.jpeg" class="d-block w-100 d-none d-lg-block" alt="...">
</div>
</div>
</div>
<div class="col-md-4 mb-3 mb-md-0">
<div class="row align-items-center">
<div class="col-2" data-aos="fade-left">
<i class="img-fluid material-icons" style="width: 100%;"><img src="images/kisspng-icon-design-web-development-responsive-web-design-black-brush-5afd4d493dd9d2.7237427015265498332534.png" alt="" style="width: 100%;"></i>
</div>
<div class="col-10 footertext" data-aos="fade-left">
<h5 class="text-start"><strong>Conception graphique & Webdesign</strong></h5>
<p class="text-start grisclaire">Logos, templates Web, plaquettes publicitaires,
cartes de visite, newsletters...</p>
</div>
<div class="col-2" data-aos="fade-left">
<i class="img-fluid material-icons" style="width: 100%;"><img src="images/3938579.png" alt="" style="width: 100%;"></i>
</div>
<div class="col-10 footertext" data-aos="fade-left">
<h5 class="text-start"><strong>Dynamisme des pages</strong></h5>
<p class="text-start grisclaire">Des animations de contenu non intrusives
pour embellir votre projet.</p>
</div>
<div class="col-2" data-aos="fade-left">
<i class="img-fluid material-icons" style="width: 100%;"><img src="images/2739572-200.png" alt="" style="width: 100%;"></i>
</div>
<div class="col-10 footertext" data-aos="fade-left">
<h5 class="text-start"><strong>Interface d'administration</strong></h5>
<p class="text-start grisclaire">Outils spécifiques au bon fonctionnement
de votre entreprise.</p>
</div>
<div class="col-2" data-aos="fade-left">
<i class="img-fluid material-icons" style="width: 100%;"><img src="images/1027666.png" alt="" style="width: 100%;"></i>
</div>
<div class="col-10 footertext" data-aos="fade-left">
<h5 class="text-start"><strong>Responsive design</strong></h5>
<p class="text-start grisclaire">Compatible tous supports, tablette & application
mobile.</p>
</div>
</div>
</div>
</div>
</div>
</section>
<div class="imagesjolie">
<div class="parallax-header" style=" background: #000;
background: linear-gradient(
rgba(0, 0, 0, 0.3),
rgba(0, 0, 0, 0.8)
),
url(1393785.jpg);
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;">
<div class="container d-flex align-items-center justify-content-center" style="height: 200px;">
<div class="header-content">
<h1 class="text-center imagebluranimation" style="color: white;">Développement Web Responsive
</h1>
<h4 class="text-center imagebluranimation" style="color: white;">Compatible Mobile, Tablettes &
P.C</h4>
</div>
</div>
</div>
</div>
<div class="imagesjolie">
<div class="parallax-header" style=" background: #000;
background: linear-gradient(
rgba(0, 0, 0, 0.3),
rgba(0, 0, 0, 0.8)
),
url(521120.jpg);
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;">
<div class="container d-flex align-items-center justify-content-center" style="height: 200px;">
<div class="header-content">
<h1 class="text-center imagebluranimation" style="color: white;"> PME, associations ou
particuliers,
je réponds à vos besoins en développement web </h1>
</div>
</div>
</div>
</div>
</br>
<div class="container text-center" id="scrollspyHeading6" style="padding-bottom: 3%;">
<h1 style="padding-top: 4%;" data-aos="fade-down">
<g>À PROPOS</g>
</h1>
<h4 style="color: rgb(117, 111, 111);" data-aos="fade-down">Je suis développeur web freelance et j'aime ça !
</h4>
<div class="row gx-4 gx-lg-5">
<div class="col-md-4 mb-3 mb-md-0" data-aos="fade-right">
<h4 class="text-start">Un développeur web passionné !</h4>
<p class="text-start grisclaire">Ma passion pour le développement web commence en 2003 et m'a
demandé un
changement
radical de cursus
afin de pouvoir pleinement l'exploiter.</br> </br>
Dès lors, je mis tout en oeuvre pour percer dans cette voie, tout en prenant du plaisir sur les
divers projets développés.</br> </br>
En Mai 2009, je décide de devenir développeur web indépendant après plusieurs postes en tant que
développeur web « full-stack » réussis, qui me conforteront dans cette idée afin de toucher un
plus
large panel de domaines d'activités, voir du pays et conquérir le monde !</p>
</div>
<div class="col-md-4 mb-3 mb-md-0 row align-items-center" data-aos="fade-up">
<div class="row align-items-center">
<div class="col">
<img src="images/index1.jpeg" class="d-block w-100 d-none d-lg-block" alt="...">
</div>
</div>
</div>
<div class="col-md-4 mb-3 mb-md-0" data-aos="fade-left">
<h4 class="text-start">Expérience en développement</h4>
<p class="text-start grisclaire"> Mon expérience acquise au fil des projets me permet de mieux
comprendre les
attentes d'un client
et de
répondre précisement au besoin demandé en fonction du domaine d'activité.</p>
<p class="text-start grisclaire">Du site vitrine au projet plus complexe, je vous propose une
expertise et un
développement web qui
correspond à vos attentes & à vos besoins.</p>
<h3 class="text-start">Un tarif adapté à votre projet</h3>
<p class="text-start grisclaire"> Travaillant régulièrement avec des PME, associations ou
particuliers, je vous
propose des solutions
à
votre portée & adaptée à votre budget.</p>
</div>
</div>
</div>
<div class="imagesjolie">
<div class="parallax-header" style=" background: #000;
background: linear-gradient(
rgba(0, 0, 0, 0.3),
rgba(0, 0, 0, 0.8)
),
url(1393769.jpg);
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;">
<div class="container d-flex align-items-center justify-content-center" style="height: 200px;">
<div class="header-content">
<h1 class="text-center imagebluranimation" style="color: white;"> Un interlocuteur unique pour
un site internet
réussi
!
</h1>
</div>
</div>
</div>
</div>
<div class="container text-center" id="scrollspyHeading7">
<h1 style="padding-top: 4%;" data-aos="fade-down">
<b>CONTACTEZ-MOI</b>
</h1>
<h3 class="footertext" style="background-color: rgb(245, 245, 245);padding: 1%;" data-aos="fade-down"><b>Une
idée ? Un projet ? N'hésitez pas à
demander un devis !
[GRATUIT]</b></h3>
<div class="row align-items-center" style="padding: 3%;">
<div class="col-md-4 mb-3 mb-md-0 text-start">
<div class="row">
<div class="col">
<div class="row" data-aos="fade-right">
<div class="col-2 align-self-center">
<i class="bi bi-geo-alt-fill w-100"></i>
</div>
<div class="col-10" style="padding-top: 3%; padding-bottom: 3px; border-bottom: 1px solid rgb(235, 232, 232);">
<h6><b>ADRESSE</b></h6>
<p>45, allée des Grives 83390 Cuers</p>
</div>
<div class="col-2 align-self-center">
<i class="bi bi-whatsapp"></i>
</div>
<div class="col-10" style="padding-top: 3%; padding-bottom: 3px; border-bottom: 1px solid rgb(235, 232, 232);">
<h6><b>Téléphone</b></h6>
<p>(+33) 6.15.42.10.45</p>
</div>
<div class="col-2 align-self-center">
<i class="bi bi-envelope-fill"></i>
</div>
<div class="col-10" style="padding-top: 3%; border-bottom: 1px solid rgb(235, 232, 232);">
<h6><b>E-mail</b></h6>
<p>contact#mcrevoulin.com</p>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-4 mb-3 mb-md-0">
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d84484.16954510748!2d7.692039647318505!3d48.56905316137844!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x4796c8495e18b2c1%3A0x971a483118e7241f!2sStrasbourg!5e0!3m2!1sen!2sfr!4v1659196020939!5m2!1sen!2sfr" width="300" height="400" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade" data-aos="fade-up"></iframe>
<!-- <iframe
src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d316530.06898113067!2d38.75890546037433!3d51.69843674434513!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x413b2f5ce874e813%3A0x48d94c0efba762bd!2sWoronesch%2C%20Oblast%20Woronesch%2C%20Russland!5e0!3m2!1sde!2sde!4v1658941426253!5m2!1sde!2sde"
width="300" height="200" style="border:0;" allowfullscreen="" loading="lazy"
referrerpolicy="no-referrer-when-downgrade"></iframe> -->
</div>
<div class="col-md-4 mb-3 mb-md-0" data-aos="fade-left">
<form id="contactForm" action="contact.php" method="POST">
<div class="input-group mb-3">
<span class="input-group-text" id="basic-addon1"><i class="bi bi-person-fill"></i></span>
<input type="text" id="name" name="name" class="form-control" placeholder="Nom Prénom"
aria-label="Nom Prénom" aria-describedby="basic-addon2" required>
</div>
<!-- Email address input -->
<div class="input-group mb-3">
<span class="input-group-text" id="basic-addon1">#</span>
<input type="text" id="email" name="email" class="form-control" placeholder="Email"
aria-label="email" aria-describedby="basic-addon1" required>
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="basic-addon1"><i class="bi bi-telephone-fill"></i></span>
<input type="text" id="phone" name="phone" class="form-control" placeholder="Téléphone"
aria-describedby="basic-addon2" required>
</div>
<!-- Message input -->
<div class="mb-3">
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3"
placeholder="Decrivez le plus possible votre projet" name="message" required></textarea>
</div>
<!-- Form submit button -->
<div class="d-grid">
<button class="btn btn-primary btn-lg" name="send" type="submit">Submit</button>
</div>
</form>
</div>
</div>
</div>
</div>
<footer style="background-color: #2c2c2c;">
<div class="container" style="padding: 5%;">
<div class="row justify-content-between gx-4 gx-lg-5">
<div class="col-md-4 mb-3 mb-md-0" data-aos="fade-right">
<h6 style="color: white;"> Développeur Informatique Indépendant</h6>
<p class="grisclaire">Développeur Web front & back-end & Webdesigner freelance, je suis à votre
disposition pour répondre à
tout type
de projets de création de sites internet, de développement spécifique ou d'applications web.
</p>
<p class="grisclaire">Passionné par les technologies liées au Web, je mets mes compétences au
service de vos besoins dans
divers
domaines.</p>
</div>
<div class="col-md-4 mb-3 mb-md-0 " data-aos="fade-left">
<h6 style="color: white;"> Mathieu CRÉVOULIN</h6></br>
<a class="grisclaire footertext" href="https://goo.gl/maps/XD9CrQDL9WXZWrWV6" style="margin-bottom: 0; text-decoration: none;"> <i class="bi bi-geo-alt"> 45, allée
des Grives 83390 Cuers </i></a></br>
<a href="https://api.whatsapp.com/send?phone=33651289271" class="grisclaire footertext" style="margin-bottom: 0; text-decoration: none;"> <i class="bi bi-whatsapp"></i> (+33)
6.15.42.10.45</a>
<p class="grisclaire footertext" style="margin-bottom: 0;"> <i class="bi bi-envelope-fill"></i>
contact#mcrevoulin.com </p>
<p class="grisclaire footertext" style="margin-bottom: 0;"><i class="bi bi-link"></i>
www.mathieu-crevoulin.com</p>
</div>
</div>
</footer>
<script src="https://unpkg.com/aos#next/dist/aos.js"></script>
<script>
AOS.init();
$(document).ready(function(){
$('#contactForm').submit(function(e){
e.preventDefault();
const $this = $(this);
// disable submit button
const $button = $(this).find('button[type="submit"]').text('Submit...').attr('disabled', 'disabled');
// send message
$.ajax({
type: 'POST',
url: 'contact.php',
data: $this.serialize(),
success: function(data){
alert("E-mail envoyé avec succès ! Merci pour votre message ! Une réponse vous sera apportée dans les plus brefs délais.");
$this[0].reset(); // reset form
},
error: function(jqXHR, textStatus, errorThrown){
alert('An error occurred. Please try again')
},
complete: function(jqXHR, textStatus){
// enable submit button
$button.text('Submit').removeAttr('disabled');
}
})
})
});
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="js/javascript.js"></script>
<script src="https://cdn.jsdelivr.net/npm/#popperjs/core#2.11.5/dist/umd/popper.min.js" integrity="sha384-Xe+8cL9oJa6tN/veChSP7q+mnSPaj5Bcu9mPX5F5xIGE0DVittaqT5lorf0EI7Vk" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0/dist/js/bootstrap.min.js" integrity="sha384-ODmDIVzN+pFdexxHEHFBQH3/9/vQ9uori45z4JjnFsRydbmQbmL5t1tQ0culUzyK" crossorigin="anonymous"></script>
</body>
</html>
I would like to do the same so that after sending an email there is an alert that appears as in the example I showed (without loading the page or sending to a new page). I tried to create a new page with an alert but I wish its done like in the example I showed. How should I do?
You can achieve this using AJAX. Try this
contact.php file
if(isset($_POST["send"])){
$body = $_POST['message'];
$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'mymail#mail.com';
$mail->Password = 'psw';
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption
$mail->Port = 465;
$mail->setFrom('mymail#mail.com');
$mail->addAddress($_POST["email"]);
$mail->isHTML(true);
$mail->Subject = 'Projet web';
$mail->Body = "Message:" . $body . "<br>Phone number: " . $phone . "<br>Name: " . $name . "<br>Mail: " . $email;
$mail->send();
// header("Location: http://127.0.0.1/test2/confirmmail.html#scrollspyHeading7");
echo 'sent';
exit;
}
index.php
<div class="col-md-4 mb-3 mb-md-0" data-aos="fade-left">
<form id="contactForm" action="contact.php" method="POST">
<div class="input-group mb-3">
<span class="input-group-text" id="basic-addon1"><i class="bi bi-person-fill"></i></span>
<input type="text" id="name" name="name" class="form-control" placeholder="Nom Prénom"
aria-label="Nom Prénom" aria-describedby="basic-addon2" required>
</div>
<!-- Email address input -->
<div class="input-group mb-3">
<span class="input-group-text" id="basic-addon1">#</span>
<input type="text" id="email" name="email" class="form-control" placeholder="Email"
aria-label="email" aria-describedby="basic-addon1" required>
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="basic-addon1"><i class="bi bi-telephone-fill"></i></span>
<input type="text" id="phone" name="phone" class="form-control" placeholder="Téléphone"
aria-describedby="basic-addon2" required>
</div>
<!-- Message input -->
<div class="mb-3">
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3"
placeholder="Decrivez le plus possible votre projet" name="message" required></textarea>
</div>
<!-- Form submit button -->
<div class="d-grid">
<button class="btn btn-primary btn-lg" name="send" type="submit">Submit</button>
</div>
</form>
</div>
Add this before the closing body tag. For submitting the form asynchronously
<script>
$(document).ready(function(){
$('#contactForm').submit(function(e){
e.preventDefault();
const $this = $(this);
// disable submit button
const $button = $(this).find('button[type="submit"]').text('Submit...').attr('disabled', 'disabled');
// send message
$.ajax({
type: 'POST',
url: 'contact.php',
data: $this.serialize(),
success: function(data){
alert("E-mail envoyé avec succès ! Merci pour votre message ! Une réponse vous sera apportée dans les plus brefs délais.");
$this[0].reset(); // reset form
},
error: function(jqXHR, textStatus, errorThrown){
alert('An error occurred. Please try again')
},
complete: function(jqXHR, textStatus){
// enable submit button
$button.text('Submit').removeAttr('disabled');
}
})
})
})
</script>
Hi guys what would be the reasons of a non working include_once?
i think something wrong in my methods because i used (class with methods and interface implemented )
Please tell me if you want more information.
i need solution beacause i'm preparing a project :/
this is my page config.php
<?php
include_once '../connexion/Connexion.php';
include_once '../Services/UtilisateurService.php';
include_once '../Services/AssocService.php';
session_start();
$nom = '';
$motpass = '';
$profile='';
$observation='';
$id = 0;
$update = false;
if (isset($_POST['save']))
{
$nom = $_POST['nom'];
$motpass = $_POST['password'];
$profile = $_POST['profil'];
$observation = $_POST['observation'];
$dot=new UtilisateurService();
$ope=new Utilisateur(NULL,$nom,$password,$profil,$observation);
$dot->create($ope);
$_SESSION['message'] = "Utilisateur Enregistre";
header('location: ../Goperateur.php');
}
if (isset($_POST['update']))
{
$es = new AssocService();
$es->update($es->finById($id));
$_SESSION['message'] = "Utilisateur Modifier!";
header('location: ./Goperateur.php');
}
if(isset($_POST['ajouter']))
{
$nom=$_POST['nom'];
$password=$_POST['password'];
$profil=$_POST['profil'];
$observation=$_POST['observation'];
$dot=new UtilisateurService();
$ope=new Utilisateur($idd,$nom,$password,$profil,$observation);
$dot->create($ope);
header("location:./Goperateur.php");
}
if (isset($_GET['id']))
{
$id = $_GET['id'];
$es = new AssocService();
$es->delete($es->findById($id));
$_SESSION['message'] = "Utilisateur suprimer";
header('location: ../Goperateur.php');
}
and this is my page index
<?php include_once './action/configOperateur.php';?>
<?php
if (isset($_GET['edit'])) {
$id = $_GET['edit'];
$update = true;
$record = mysqli_query($db, "SELECT * FROM utilisateur WHERE id_utilisateur=$id");
if (count($record) == 1 ) {
$n = mysqli_fetch_array($record);
$nom = $n['nom'];
$motpass = $n['mot_passe'];
$profile=$n['profil'];
$observation=$n['observation'];
}
}
?>
</head>
<body>
<div id="wrapper">
<nav class="navbar navbar-default navbar-cls-top " role="navigation" style="margin-bottom: 0">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div style="color: white;
padding: 15px 50px 5px 50px;
float: right;
font-size: 16px;">
<script> document.write(new Date().toLocaleDateString()); </script>
Se déconnecter </div>
</nav>
<!-- /. NAV TOP -->
<nav class="navbar-default navbar-side" role="navigation">
<div class="sidebar-collapse">
<ul class="nav" id="main-menu">
<li class="text-center">
<img src="assets/img/radeema.png" class=""/>
</li>
<li>
<i class="fa fa-dashboard fa-3x"></i>Tableau de bord
</li>
<li>
<i class="fa fa-desktop fa-3x"></i> Gestion des Operateurs
</li>
<li>
<i class="fa fa-cloud" style="font-size:36px"></i> Gestion de Dotation
</li>
<li>
<i style="font-size:36px" class="fa"></i> Gestion des Puces
</li>
<li >
<i class="fa fa-table fa-3x"></i> Gestion Des Entites
</li>
<li >
<i class="fa fa-male" style="font-size:36px"></i> Gestion de Personnels
</li>
<li >
<i class="fa fa-male" style="font-size:36px"></i> Association Personnels-Puces
</li>
</ul>
</div>
</nav>
<!-- /. NAV SIDE -->
<div id="page-wrapper" >
<div id="page-inner">
<div class="row">
<div class="col-md-12">
<h2>Gestion des operateurs </h2>
<h5> </h5>
</div>
</div>
<!-- /. ROW -->
<hr />
<?php if (isset($_SESSION['message'])): ?>
<div style="margin: 30px auto;
padding: 10px;
border-radius: 5px;
color: #3c763d;
background: #dff0d8;
border: 1px solid #3c763d;
width: 50%;
text-align: center;">
<?php
echo $_SESSION['message'];
unset($_SESSION['message']);
?>
</div>
<?php endif ?>
<div class="row">
<div class="col-md-12">
<!-- Form Elements -->
<div class="panel panel-default">
<div class="panel-heading">
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-6">
<form method="post" action="">
<div class="form-group">
<label>Nom</label>
<input type="text" name="nom" class="form-control" placeholder="entre le nom Complet" value="<?php echo $nom; ?>"/>
</div>
<div class="form-group">
<label>Mot de Pass</label>
<input type="text" name="password" class="form-control" placeholder="entre mot de pass" value="<?php echo $motpass; ?>"/>
</div>
<div class="form-group">
<label>Selectioner le profil</label>
<select name="profil" class="form-control">
<?php if($profile=='operateur')
{?>
<option value="admin">Operateur</option>
<option value="operateur">Admin</option>
<?php }
else
{
?>
<option value="admin">Admin</option>
<option value="operateur">Operateur</option>
<?php }?>
</select>
</div>
<div class="form-group">
<label>Observation</label>
<textarea type="text" name="observation" class="form-control" rows="3" ><?php echo $observation; ?></textarea>
</div>
<?php if ($update == false): ?>
<button class="btn btn-primary" type="submit" name="ajouter" >Ajouter</button>
<?php else: ?>
<button class="btn " type="submit" name="update" style="background: #556B2F;" >Modifier</button>
<?php endif ?>
<button name="annuler" type="reset" class="btn btn-default">Annuler</button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<hr/>
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
Liste des Operateur
</div>
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th>Nom</th>
<th>Motsepass</th>
<th>Profil</th>
<th>Observation</th>
<th>Modifier</th>
<th>Suprimer</th>
</tr>
</thead>
<tbody>
<tr class="odd gradeX">
<?php
require_once './Services/UtilisateurService.php';
require_once './Classes/Utilisateur.php';
$dot=new UtilisateurService();
foreach ($dot->findAll() as $key=>$e)
{
?>
<form method="post" action="Operateur.php">
<tr>
<td class="center"><?php echo $e->getNom();?></td>
<td class="center"><?php echo $e->getMotdepasse();?></td>
<td class="center"><?php echo $e->getProfil();?></td>
<td class="center"><?php echo $e->getObservation();?></td>
<td>Modifier</td>
<td>Suprimer</td>
</tr>
<?php
}
?>
</tr>
</tbody>
</table>
So when a customer fills in their e-mail I would like to take that e-mail and use it to display their account information and orders. (Some stuff is in dutch, if you need something translated let me know). BTW first time posting let me know
<?php
session_start();
include("functies.php");
include("header.php");
?>
<link rel="stylesheet" href="styling.css" type="text/css"/>
<div align="center">
<?php logo() ?>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-offset-4 col-md-3">
<div class="form-login">
<form action="homepagina.php" method="post">
<div align="center"><h4>Welkom terug!</h4></div>
<p align ="left">E-mailadres*</p>
<input name="email" type="text" class="form-control input-sm chat-input" placeholder="Email" required>
</br>
<p align="left">Wachtwoord*</p>
<input type="password" class="form-control input-sm chat-input" placeholder="Wachtwoord" required>
</br>
<div class="wrapper">
<span class="group-btn">
Inloggen <i class="fa fa-sign-in"></i>
<br><br>Nog geen account? Maak er een aan
</span>
</div>
</form>
</div>
</div>
</div>
</div>
<?php
$_SESSION['email']=$_POST;
?>
**Next up the accountpage. **
<?php
session_start();
include("functieshomepagina.php");
include("header.php");
include("dbconnect.php");
$klantenmail = $_SESSION['email'];
var_dump($_SESSION);
$customer_ID_query = mysqli_query($conn, "SELECT id FROM customers WHERE customer_email = '$klantenmail' ");
$customer_ID=[];
while($row = mysqli_fetch_array($customer_ID_query)){
$customer_ID[] = $row;
}
//functie voor de account informatie van een specifieke klant voor de accountpagina
$klantenquery = mysqli_query($conn, "SELECT id, first_name, middle_name, last_name, customer_email FROM customers WHERE id = '{$customer_ID[0][0]}'");
$klanten=[];
while($row = mysqli_fetch_array($klantenquery)){
$klanten[] = $row;
}
//functie voor de account informatie van een specifieke klant voor de bestelling op de accountpagina
$bestellingquery = mysqli_query($conn, "SELECT id, date_placed, date_paid, total_price, customers_id FROM orders WHERE customers_id = '{$customer_ID[0][0]}'");
$bestelling=[];
while($row = mysqli_fetch_array($bestellingquery)){
$bestelling[] = $row;
}
?>
<div align="center">
<?php logo();?>
</div>
<div class="container-fluid well span6">
<div class="row-fluid">
<div class="span2" >
<img width ='200' src="http://localhost/Avatar_man.png" class="img-circle">
</div>
<div class="span8">
<h3><?php echo $klanten[0][1] ." ".$klanten[0][2] . " ".$klanten[0][3]?></h3>
<h6>Email: <?php echo $klanten[0][4] ?></h6>
<h6>Klanten nummer: <?php echo $klanten[0][0]?></h6>
<h6></h6>
</div>
</div>
</div>
<!--Begin van Bestellingen tabel-->
<link rel="stylesheet" href="styling.css" type="text/css"/>
<div class="container">
<div align="center">
<h2>Bestellingen</h2>
</div>
<table class="table table-hover table-bordered">
<thead class="thead-success">
<tr>
<th>Order ID</th>
<th>Datum plaatsen van bestelling</th>
<th>Datum van betaling</th>
<th>Totaal prijs</th>
</tr>
</thead>
<tbody>
<?php
foreach ($bestelling as $key => $value) {
?>
<tr>
<td><?php echo $value[0]?></td>
<td><?php echo $value[1]?></td>
<td><?php echo $value[2]?></td>
<td><?php echo "€ " . number_format($value[3],2)?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<?php
Include("footer.php")
?>
**So when the customer enters their email I'd like to take that email using session to put it in at the accountpage. Ive seen several methods but it doesn't seem to be working. Any help would be appreciated. **
At the end of your HTML form you have:
$_SESSION['email']=$_POST
It needs to be:
$_SESSION['email']=$_POST['email']
and you need to move that line of code into homepagina.php in order for it to capture the session variable. Or you're trying to capture a variable that hasn't been submitted.
You need to reference the name of the input that you want to grab using POST.
Could you guys help me with following problem:
my code:
<?php
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
if ($_POST['submit']) {
if (!$_POST['name']) {
$error="<br/>- S'il vous plaît entrez votre nom";
}
if (!$_POST['email']) {
$error.="<br/>- S'il vous plaît entrez votre email adresse";
}
if (!$_POST['message']) {
$error.="<br/>- S'il vous plaît entrez le message";
}
if (!$_POST['check']) {
$error.="<br/>- s'il vous plaît confirmer que vous êtes humain";
}
if ($error) {
$result='<div class="alert alert-danger" role="alert"> <strong> oups, vous avez un erreur : </strong>'.$error.'</div>';
} else {
mail("1992rax#gmail.com", "contact message", "<br> Name: ".$_POST['name']."<br> Email: ".$_POST['email']."<br> Message: ".$_POST['message'],$headers);
$result='<div class="alert alert-success" role="alert"> merci votre message a été envoyer</div>';
}
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<title>fowaj project website</title>
<meta charset="utf-8" >
<meta name="author" content="oussama el badaoui" >
<meta name="description" content="this is an website comunity gallery of images hummour">
<meta name="viewport" content="width=device-width, initial-scale=1.0" >
<link rel="icon" href="favicon.png">
<!--[if IE]><link rel="shortcut icon" href="favicon.ico"><![endif]-->
<!-- Bootstrap main css -->
<link href="layout/css/bootstrap.css" rel="stylesheet">
<!-- custom css -->
<link href="layout/css/custom.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.php">
<img src="layout/images/logo.png" alt="fowaj project" />
</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active">Accueil <span class="sr-only">(current)</span></li>
<li>Contacte</li>
<li>Politique de confidentialité</li>
<li>termes et conditions</li>
<li>à propose</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></button>
</form>
<li>Connexion</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<section id="contact">
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<h1>contact formulaire </h1>
<?php echo $result;?>
<p> envoyer votre message par cette formulaire</p>
<form method="post" role="form">
<div class="form-group">
<input type="text" name="name" class="form-control" placeholder="enter votre nome" value="<?php echo $_POST['name'];?>">
</div>
<div class="form-group">
<input type="email" name="email" class="form-control" placeholder="enter votre email" value="<?php echo $_POST['email'];?>">
</div>
<div class="form-group">
<textarea name="message" rows="5" class="form-control" placeholder="enter votre message ..."><?php echo $_POST['message'];?></textarea>
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="check"> je suis humain
</label>
</div>
<div align="center">
<input type="submit" name="submit" class="btn btn-secondary" value="envoyer le message" />
</div>
</form>
</div>
</div>
</div>
</section>
<footer>
<div class="list-group col-md-4">
<a class="list-group-item active">Catégories:</a>
<a class="list-group-item" href="#">Caricatures</a>
<a class="list-group-item" href="#">Cinéma et tv</a>
<a class="list-group-item" href="#">Politique</a>
<a class="list-group-item" href="#">enfants</a>
<a class="list-group-item" href="#">animaux</a>
</div>
<div class="list-group col-md-4">
<a class="list-group-item active">les Pages de site:</a>
<a class="list-group-item" href="contact.php">Contacter Nous</a>
<a class="list-group-item" href="Privacy-policy.htm">Politique de confidentialité</a>
<a class="list-group-item" href="term-and-conditions.htm">termes et conditions</a>
<a class="list-group-item" href="about-us.htm">à propose de Nous</a>
<a class="list-group-item" href="#" data-toggle="modal" data-target="#regModal" >ajouter votre image</a>
</div>
<div class="list-group col-md-4">
<a class="list-group-item active">média sociaux:</a>
<a class="list-group-item" href="http://facebook.com/fowajproject" target="new">facebook</a>
<a class="list-group-item" href="http://twitter.com/fowajproject" target="new">twitter</a>
<a class="list-group-item" href="http://youtube.com/fowajproject" target="new">youtube</a>
<a class="list-group-item" href="http://plus.google.com/fowajprojetc" target="new">google plus</a>
</div>
<div class="col-md-12 col-sm-12 footer-info">
copyright © 2016 fowaj project made in morocco by oussama el badaoui
</div>
</footer>
</body>
</html>
You haven't defined $header!!! At the top of your file you have:
<?php
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
You are appending with .= something to a variable that doesn't exist!
Instead, simply define $headers with =:
<?php
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
That should do the trick.
You should add the code from the dropbox link you gave me in your first post.
You should try this:
if (isset($_POST['submit']) && $_POST['submit']) {
if (!$_POST['name']) {
$error = "<br/>- S'il vous plaît entrez votre nom";
}
if (!$_POST['email']) {
$error = "<br/>- S'il vous plaît entrez votre email adresse";
}
if (!$_POST['message']) {
$error = "<br/>- S'il vous plaît entrez le message";
}
if (!$_POST['check']) {
$error = "<br/>- s'il vous plaît confirmer que vous êtes humain";
}
if ($error) {
$result='<div class="alert alert-danger" role="alert"> <strong> oups, vous avez un erreur : </strong>'.$error.'</div>';
} else {
mail("1992rax#gmail.com", "contact message", "<br> Name: ".$_POST['name']."<br> Email: ".$_POST['email']."<br> Message: ".$_POST['message'],$headers);
$result ='<div class="alert alert-success" role="alert"> merci votre message a été envoyer</div>';
}
}
I am working in a accounting system, then i want display the users when search by lastname or document, here is my
search.php
$busqueda = $_POST['busqueda'];
mysql_select_db($database_connectBD_fc, $connectBD_fc);
//busqueda por cedula
$query_registroClientes = "SELECT * FROM clientes WHERE num_documento LIKE '".$busqueda."' ORDER BY apellidos,nombres";
$registroClientes = mysql_query($query_registroClientes, $connectBD_fc) or die(mysql_error());
$row_registroClientes = mysql_fetch_assoc($registroClientes);
//busqueda por nombre
$query_busquedaClientes = "SELECT * FROM clientes WHERE apellidos LIKE '%".$busqueda."%' ORDER BY apellidos,nombres";
$busquedaClientes = mysql_query($query_busquedaClientes, $connectBD_fc) or die(mysql_error());
$row_busquedaClientes = mysql_fetch_assoc($busquedaClientes);
?>
<?php
include 'dbc.php';
page_protect();
?>
<?php if($row_busquedaClientes==0){
echo "<p class='text-success'>Búsqueda por apellido(s)</p>";?>
<table class="tablas container-fluid">
<tr class="tabla1 row">
<td class="col-md-2">Apellidos</td>
<td class="col-md-2 c-borde">Nombre</td>
<td class="col-md-3">Correo Electronico</td>
<td class="col-md-2 c-borde">Teléfono</td>
<td class="col-md-1">Fecha ingreso</td>
<td class="col-md-1 c-borde">Activo</td>
<td class="col-md-1">Acciones</td>
</tr>
<?php do { ?>
<tr class="info row">
<td style="text-transform:Capitalize;"><strong><?php echo $row_busquedaClientes['apellidos']; ?></strong></td>
<td class="c-borde" style="text-transform:Capitalize;"><?php echo $row_busquedaClientes['nombres']; ?></td>
<td><?php if($row_busquedaClientes['correo'] == False){
echo "<div class='label label-danger'><strong>No hay correo asignado.</strong></div>";
}else{
echo $row_busquedaClientes['correo'];
} ?></td>
<td class="c-borde"><?php echo $row_busquedaClientes['telefono']; ?></td>
<td><?php echo $row_busquedaClientes['fecha_ingreso']; ?></td>
<td class="c-borde">
<?php
if($row_busquedaClientes['activo']=="1"){
echo "<span class='label label-success'>Si</div>";
}
else if($row_busquedaClientes['activo']=="0"){
echo "<span class='label label-danger'>No</div>";} ?>
</td>
<td>
<?php
if($row_busquedaClientes['idCliente']==""){echo " ";}
else{?>
<a href="clientesActualizar.php?num_cliente=<?php echo $row_busquedaClientes['idCliente']; ?>">
<i class="fa fa-pencil-square-o" title="Editar" style="color: #A5C63B; font-size: 20px;"></i>
</a>
<a href="clientesDetalles.php?num_cliente=<?php echo $row_busquedaClientes['idCliente']; ?>">
<i class="fa fa-eye" title="Ver detalles" style="color: #A5C63B; font-size: 20px;border:1px solid; border-width:0px 1px;padding:0 10px;"></i>
</a>
<a onclick="Borra('<? echo $row_busquedaClientes['idCliente']; ?>');" href="#">
<i class="fa fa-trash-o" title="Eliminar" style="color: #dd2e3e; font-size: 20px;"></i>
</a>
<?php } ?>
</td>
</tr>
<?php } while ($row_busquedaClientes = mysql_fetch_assoc($busquedaClientes)); ?>
</table> <?php } ?>
<?php
mysql_free_result($busquedaClientes);
?>
the idea is take the information the user and display in another page where i show all the users who are in the data base, here is where i show the search result
<div class="container botones-busqueda col-md-12">
<div class="container">
<div class="col-md-6">
<a class="btn btn-danger btn-nuevo-cliente" href="clientesNew.php" role="button">Nuevo Cliente</a>
<a class="btn btn-warning" href="vencimientos.php" role="button">Proximos a vencer</a>
<a class="btn btn-default" href="vencidos.php" role="button">Vencidos</a>
</div>
<div class="col-md-3 col-md-offset-3">
<form name="busqueda" id="busqueda" method="post" action="">
<input type="text" name="busquedas" id="busquedas" style="color:black;" placeholder="Buscar, por apellidos">
<input title="Buscar" class="fa fa-search" id="buscar" type="submit" value="Buscar">
<label for="cedula"></label>
</form>
<?php
if (isset($_GET['msg'])) {
echo "<div class=\"error\">$_GET[msg]</div>";
}
?>
</div>
</div>
</div>
<section class="container">
<div id="resultado"></div>
</section>
is where i display all the users, using the code <?php do{} while ($row_registroClientes = mysql_fetch_assoc($registroClientes)); ?> inside display all the users, well i hope someone can help me.
here is my ajax code
<script language="JavaScript">
function Borra(idcontacto)
{
var agree=confirm("¿Realmente desea eliminar el contacto seleccionado?");
if (agree) { document.location="clientesDel.php?num_cliente="+idcontacto; }
else return false ;
}
$(function(){
$('#busquedas').focus();
$('#busqueda').submit(function(e){
e.preventDefault();
})
$('#busquedas').keyup(function(){
var envio = $('#buscar').val();
$('#resultado').html('<p class="text-success">Buscando al cliente.</p>');
$.ajax({
type: 'POST',
url: 'busqueda.php',
data: ('busqueda='+envio),
success: function(resp){
if (resp!="") {
$('#resultado').html(resp);
}
}
})
})
})
</script>
Thanks you.