File "code01.php"
Full Path: /home/analogde/www/Outlook/Fusion/formulaire_bootstrap/code01.php
File size: 8.33 KB
MIME-type: text/html
Charset: utf-8
<!--
https://bootstrapbay.com/blog/working-bootstrap-contact-form/
-->
<?php
$string = "797aDF1";
if(ctype_alnum($string)){
echo "Yes, It's an alphanumeric string/text";
}
else{
echo "No, It's not an alphanumeric string/text";
}
$errName = "";
$errEmail = "";
$errpass1 = "";
$errpass2 = "";
if (isset($_POST["submit"])) {
$name = $_POST['name'];
$email = $_POST['email'];
$password = $_POST['password'];
$confirme = $_POST['confirme'];
if ($password != $confirme )
{
$errpass2 = 'Pas identique ???';
}
//$message = $_POST['message'];
//$human = intval($_POST['human']);
//$from = 'Demo Contact Form';
//$to = 'example@bootstrapbay.com';
//$subject = 'Message from Contact Demo ';
//$body = "From: $name\n E-Mail: $email\n Message:\n $message";
// Check if name has been entered
if (!$_POST['name']) {
$errName = 'Please enter your name';
}
if( strlen($email) < 6)
{
$errName = 'Trop court !!!!';
}
// Check if email has been entered and is valid
if (!$_POST['email'] || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
$errEmail = 'Please enter a valid email address';
}
//Check if message has been entered
/*if (!$_POST['message']) {
$errMessage = 'Please enter your message';
}
//Check if simple anti-bot test is correct
if ($human !== 5) {
$errHuman = 'Your anti-spam is incorrect';
}*/
if (!$errName && !$errEmail )
{
//if (mail ($to, $subject, $body, $from))
//{
$result='<div class="alert alert-success">Thank You! I will be in touch</div>';
//}
//else {
// $result='<div class="alert alert-danger">Sorry there was an error sending your message. Please try again later</div>';
//}
}
}
?>
<!--
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/css/bootstrap.min.css" integrity="sha384-r4NyP46KrjDleawBgD5tp8Y7UzmLA05oM1iAEQ17CSuDqnUK2+k9luXQOfXJCJ4I" crossorigin="anonymous">
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<script>
function validatePassword(password) {
const strongPasswordRegex =
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/;
const errorMessage = document.getElementById('errorMessage');
// Check each condition and update the corresponding label
document.getElementById('minLength').innerHTML =
password.length >= 8 ?
'<i class="fas fa-check text-success"></i> Minimum 8 characters' :
'<i class="fas fa-times text-danger"></i> Minimum 8 characters';
document.getElementById('uppercase').innerHTML =
/[A-Z]/.test(password) ?
'<i class="fas fa-check text-success"></i> At least one uppercase letter' :
'<i class="fas fa-times text-danger"></i> At least one uppercase letter';
document.getElementById('lowercase').innerHTML =
/[a-z]/.test(password) ?
'<i class="fas fa-check text-success"></i> At least one lowercase letter' :
'<i class="fas fa-times text-danger"></i> At least one lowercase letter';
document.getElementById('symbol').innerHTML =
/[@$!%*?&]/.test(password) ?
'<i class="fas fa-check text-success"></i> At least one symbol (@$!%*?&)' :
'<i class="fas fa-times text-danger"></i> At least one symbol (@$!%*?&)';
// Check overall validity and update the error message
if (strongPasswordRegex.test(password)) {
errorMessage.textContent = 'Strong Password';
errorMessage.classList.remove('text-danger');
errorMessage.classList.add('text-success');
} else {
errorMessage.textContent = 'Weak Password';
errorMessage.classList.remove('text-success');
errorMessage.classList.add('text-danger');
}
}
</script>
<form class="form-horizontal" role="form" method="post" action="code01.php">
<div class="form-group">
<label for="name" class="col-sm-2 control-label">Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="name" name="name"
title="Must contain at least one number and one uppercase and lowercase letter, and at least 8 or more characters"
pattern="^[_A-z0-9]{1,}$" minlength="6" placeholder="First & Last Name" >
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
<?php echo "<p class='text-danger'>$errName</p>";?>
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="email" name="email" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$" placeholder="example@domain.com" >
<?php echo "<p class='text-danger'>$errEmail</p>";?>
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-2 control-label">Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="password" name="password" oninput="validatePassword(this.value)"> placeholder="password ......" >
<?php echo "<p class='text-danger'>$errpass1</p>";?>
</div>
</div>
<div class="form-group">
<ul>
<li id="minLength"><i class="fas fa-times
text-danger"></i> Minimum 8 characters</li>
<li id="uppercase"><i class="fas fa-times
text-danger"></i> At least one uppercase
letter</li>
<li id="lowercase"><i class="fas fa-times
text-danger"></i> At least one lowercase
letter</li>
<li id="symbol"><i class="fas fa-times
text-danger"></i>
At least one symbol (@$!%*?&)
</li>
</ul>
</div>
<span id="errorMessage" class="font-weight-bold
text-danger"></span>
<div class="form-group">
<label for="password" class="col-sm-2 control-label">Confirme password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="confirme" name="confirme" placeholder="encore une fois le password ......" >
<?php echo "<p class='text-danger'>$errpass2</p>";?>
</div>
</div>
<!--
<div class="form-group">
<label for="message" class="col-sm-2 control-label">Message</label>
<div class="col-sm-10">
<textarea class="form-control" rows="4" name="message"><?php echo htmlspecialchars($_POST['message']);?></textarea>
<?php //echo "<p class='text-danger'>$errMessage</p>";?>
</div>
</div>
<div class="form-group">
<label for="human" class="col-sm-2 control-label">2 + 3 = ?</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="human" name="human" placeholder="Your Answer">
<?php //echo "<p class='text-danger'>$errHuman</p>";?>
</div>
</div>
-->
<div class="form-group">
<div class="col-sm-10 col-sm-offset-2">
<input id="submit" name="submit" type="submit" value="Send" class="btn btn-primary">
</div>
</div>
<div class="form-group">
<div class="col-sm-10 col-sm-offset-2">
<?php echo $result; ?>
</div>
</div>
</form>
<!--
<form data-toggle="validator" role="form">
<div class="form-group">
<label class="control-label" for="Password">Password</label>
<input type="password" data-minlength="6" class="form-control" id="Password" placeholder="Enter your name" required />
<div class="help-block with-errors">Minimum of 6 characters</div>
</div>
<div class="form-group">
<label class="control-label" for="ConfirmPassword">Confirm Password</label>
<input type="password" class="form-control" id="ConfirmPassword" data-match="#Password" data-match-error="Whoops, Password not match" placeholder="Confirm Password" required />
<div class="help-block with-errors"></div>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
-->
</body>
</html>