How to show success message on form submit using sweet alert in php

preview_player
Показать описание
#html #css #php #mysql#phpcrud

show success message After Click Submit Button

Source Code is in discription

how to show status message using sweet alert in php,how to show success message after form submit in php,sweet alert in php,how to use sweet alert in php,how to display success message after saving data in php,show error messages using php,CodingHerohow to show success msg in phpdisplay status using sweet alert in php
Рекомендации по теме
Комментарии
Автор

Connection.php

<?php

$server = "localhost"; //your ip and port
$user = "root"; //username by default give it root
$pass = ""; // default password is empty
$databse="youtube"; // database name

$conn=mysqli_connect($server, $user, $pass, $databse);

if($conn){
echo "Connected";
}else{
echo "Not Connected";
}


?>




register.php



<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
font-family: Arial, Helvetica, sans-serif;
background-color: white;
}

* {
box-sizing: border-box;
}

/* Add padding to containers */
.container {
padding: 16px;
background-color: white;
}

/* Full-width input fields */
input[type=email], input[type=password] {
width: 100%;
padding: 15px;
margin: 5px 0 22px 0;
display: inline-block;
border: none;
background: #f1f1f1;
}

input[type=email]:focus, input[type=password]:focus {
background-color: #ddd;
outline: none;
}

/* Overwrite default styles of hr */
hr {
border: 1px solid #f1f1f1;
margin-bottom: 25px;
}

/* Set a style for the submit button */
.registerbtn {
background-color: #04AA6D;
color: white;
padding: 16px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
opacity: 0.9;
}

.registerbtn:hover {
opacity: 1;
}

/* Add a blue text color to links */
a {
color: dodgerblue;
}

/* Set a grey background color and center the text of the "sign in" section */
.signin {
background-color: #f1f1f1;
text-align: center;
}
</style>
</head>
<body>

<form method="post">

<div class="container">
<h1>Register</h1>
<p>Please fill in this form to create an account.</p>
<hr>

<label
<input type="email" placeholder="Enter Email" name="email" id="email" required>

<label
<input type="password" placeholder="Enter Password" name="password" id="psw" required>

<hr>

<button type="submit" name="submit"
</div>

</form>

</body>
</html>







<?php

include 'connection.php';



if(isset($_POST['submit'])){

$email = $_POST['email'];
$password = $_POST['password'];


$insert = "insert into video(email, password)values('$email', '$password')";

$query= mysqli_query($conn, $insert);

if($query){

?>

<script>

swal({
title: "Success",
text: "Data insertd",
icon: "success",
});



</script>

<?php

}else{

?>

<script>

swal({
title: "Failed",
text: "Data not insertd",
icon: "error",
});



</script>

<?php


}


}


?>

RealCodingHero
Автор

My connection is right i write same code all work but alert pop not show submit data

Darkfact_
Автор

thanks for this! its working for me but how to redirect to Login Page after clicking that Ok ??

franzmclay
Автор

when refresh page the alert auto triggerd it how to fix not to tiggerd it bro just only button can triggerd it

OnlyAm
Автор

I give you PHP you can add success message in php

animeshorts
Автор

I give you PHP you can add success message in php

trailersHomeind