Getting errors after changing HTML file to PHP - php

I changed my html file to php in order to show php errors in form , I wasn't sure if I suppose to add or reduce php/html tags. I left as it is. When I open my form in browser its showing me the following errors. :
Notice: Undefined variable: name_error in C:\xampp\htdocs\BootstrapLandinPage\index.php on line 165
Notice: Undefined variable: lastname_error in C:\xampp\htdocs\BootstrapLandinPage\index.php on line 170
Notice: Undefined variable: phone_error in C:\xampp\htdocs\BootstrapLandinPage\index.php on line 175
and etc.
Basically every input showing an error.
My index.php:
<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">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Bootstrap 101 Template</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="font-awesome-4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/animate.min.css">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!--NAVIGATION-->
<div id="myNavbar" class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header navbar-right">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
Hello Dolly
</div>
<div class="navbar-collapse collapse" id="mainpanel">
<ul class="nav navbar-nav ">
<li>dolly</li>
<li>holly</li>
<li>holly</li>
<li>holly</li>
<li>holly</li>
<li>holly</li>
</ul>
</div>
</div>
</div>
<!--- Header ---->
<section class="parallax">
<div class="parallax-inner">
<div id="header" class="header">
<div class="container">
<div class="row">
<div class="col-md-6 wow bounceInLeft navbar-right">
<h1 class="text-right" id="main-title">dolly </h1>
<h2 class="text-right" id="changed-title">dolly</h2><br><br>
<!--- <button class="btn btn-lg btn-primary navbar-right">dolly</button> ---->
</div>
</div>
</div>
</div>
</div>
</section>
<!-- [CONTACT] -->
<section class="inspiration" id="three">
<div class="overlay">
<div class="container">
<div class="row">
<article class="col-md-12 text-center">
<div class="intermediate-container">
<div class="heading">
<h2>יש לכם שאלה? צרו איתי קשר</h2>
</div>
<div class="row">
<div class="col-md-3 col-sm-3"></div>
<div class="col-md-6 center-block col-sm-6 ">
<form id="mc-form" action ="send.php" method="POST">
<div class="form-group col-xs-12 ">
<label for="name" hidden >שם פרטי</label>
<input type="text" name="name" id="name" class="cv form-control" value="<?= $name ?>" placeholder="שם פרטי" >
<span class="error"><?= $name_error ?></span>
</div>
<div class="form-group col-xs-12 ">
<label for="lastName" hidden>שם משפחה</label>
<input type="text" name="lastName" id="lastName" class="cv form-control" value="<?= $lastName ?>" placeholder="שם משפחה" >
<span class="error"><?= $lastname_error ?></span>
</div>
<div class="form-group col-xs-12 ">
<label for="phone" hidden>טלפון</label>
<input type="text" name="phone" id="phone" class="cv form-control" value="<?= $phone ?>" placeholder="טלפון" >
<span class="error"><?= $phone_error ?></span>
</div>
<div class="form-group col-xs-12 ">
<label for="email" hidden>דואר אלקטרוני</label>
<input type="email" name="email" id="email" class="cv form-control" value="<?= $email ?>" placeholder="דואר אלקטרוני" >
<span class="error"><?= $email_error ?></span>
</div>
<div class="form-group col-xs-12 ">
<label for="subject" hidden>נושא</label>
<input type="text" name="subject" id="subject" class="cv form-control" value="<?= $subject?>" placeholder="נושא" >
</div>
<div class="form-group col-xs-12 ">
<label for="message" hidden>הודעה</label>
<textarea name="message" id="message" class="cv form-control message" placeholder="השאירו את הודעתכם פה" rows="4" cols="50"></textarea>
</div>
<input type="submit" id="submit-button" class="btn btn-custom-outline " value="שלח" >
<br>
<div class="success"><?= $success ?></div>
<!--<span class="error"></span> -->
</form>
</div>
</div>
</div>
</article>
</div>
</div>
</div>
</section>
<!-- [/CONTACT] -->
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" ></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" ></script>
<script src="js/bootstrap.min.js" ></script>
<!-- [ SLIDER SCRIPT ] -->
<script type="text/javascript" src="js/SmoothScroll.js"></script>
<script src="js/script.js" ></script>
</body>
</html>
send.php:
// define variables and set to empty values
$name_error = $lastname_error = $email_error = $phone_error = "";
$name = $lastName = $email = $phone = $message = $subject = $success = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name"])) {
$name_error = "Name is required";
} else {
$name = test_input($_POST["name"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[a-zA-Zא-ת ]*$/",$name)) {
$name_error = "Only letters and white space allowed";
}
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["lastName"])) {
$lastname_error = "Name is required";
} else {
$lastname = test_input($_POST["lastName"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[a-zA-Zא- ]*$/",$lastName)) {
$lastname_error = "Only letters and white space allowed";
}
}
if (empty($_POST["email"])) {
$email_error = "Email is required";
} else {
$email = test_input($_POST["email"]);
// check if e-mail address is well-formed
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$email_error = "Invalid email format";
}
}
if (empty($_POST["phone"])) {
$phone_error = "Phone is required";
} else {
$phone = test_input($_POST["phone"]);
// check if e-mail address is well-formed
if (!preg_match("/^(\d[\s-]?)?[\(\[\s-]{0,2}?\d{3}[\)\]\s-]{0,2}?\d{3}[\s-]?\d{4}$/i",$phone)) {
$phone_error = "Invalid phone number";
}
}
if (empty($_POST["subject"])) {
$subject = "";
} else {
$subject = test_input($_POST["subject"]);
}
if (empty($_POST["message"])) {
$message = "";
} else {
$message = test_input($_POST["message"]);
}
if ($name_error == '' and $email_error == '' and $phone_error == '' and $lastname_error == '' ){
$message_body = '';
unset($_POST['submit']);
foreach ($_POST as $key => $value){
$message_body .= "$key: $value\n";
}
$to = 'ilonasemyweb#gmail.com';
$subjectm = 'Contact Form Submit';
if (mail($to, $subjectm, $message)){
$success = "Message sent, thank you for contacting us!";
$name = $lastName = $email = $phone = $message = $subject = '';
}
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}

What you need to do is the following:
In index.php: Check if those variables are defined. If not, then there are no errors, so display nothing of that sorts, just as it would be on first entry.
In send.php: Properly send back index.php on error. This can be done using the require_once method.
So after checking all sent data for errors write:
if(/* there were errors */)
require_once("path/to/index.php");
This will then get all the text from index.php, "put it in that place in index.php" and continue interpreting. Using this, all variables defined in send.php are now also defined in index.php (and retain their values, of course). Note however that the new url will now end with send.php, unless you trick around that a bit.

Related

PHP Error: all fields are required

I am new to PHP (took some classes in college but its been a long time) and I keep getting this error when I submit my form Im not sure where the error is coming from and its driving me crazy! The error says: Error: all fields are required. This pops up when all the form fields have been filled out. Thank you to anyone that can help!
Here is my HTML:
{
<section id="book-appointment" class="book-appointment gray" style="padding-top: 100px">
<div class="grid-container grid-container-padded shadow radius">
<div class="grid-x">
<div class="cell small-12">
<header class="section-head">
<h3 class="section-title text-center ">
Say Hello!
</h3><!-- /.section-title -->
<div class="section-head-actions text-center">
Reach us for any questions you might have
</div><!-- /.section-head-actions -->
</header><!-- /.section-head -->
</div>
<div class="section-body">
<form data-abide novalidate>
<!-- First Name -->
<div class="grid-x grid-margin-x">
<div class="cell small-12 medium-6">
<label><p>First Name</p>
<input type="text" name="firstname" placeholder="First Name" aria-describedby="exampleHelpText" required>
</label>
</div>
<!-- Last Name -->
<div class="cell small-12 medium-6">
<label><p>Last Name</p>
<input type="text" name="lastname" placeholder="Last Name" aria-describedby="exampleHelpText" required>
</label>
</div>
<!-- Email -->
<div class="cell small-12 medium-6">
<label><p>Email</p>
<input type="email" name="email" placeholder="Email" aria-describedby="exampleHelpText" required>
</label>
</div>
<!-- Organization Name -->
<div class="cell small-12 medium-6">
<label><p>Organization Name</p>
<input type="text" name="orgname" placeholder="Organization" aria-describedby="exampleHelpText" required>
</label>
</div>
<!-- Board Memebers -->
<div class="cell small-12 medium-6">
<label><p>Board Members</p>
<input type="text" name="board" placeholder="Board Memebers" aria-describedby="exampleHelpText" required>
</label>
</div>
<!-- Info -->
<div class="cell small-12 medium-6">
<label><p>Organization Info? </p>
<input type="text" name="info" placeholder="Organization Info" aria-describedby="exampleHelpText" required>
</label>
</div>
<!-- Budget -->
<div class="cell small-12 medium-6">
<label><p>Budget</p>
<input type="text" name="budget" placeholder="Budget" aria-describedby="exampleHelpText" required>
</label>
</div>
</div><!-- /.grid-x .grid-margin-x -->
<!-- Textarea -->
<div class="grid-x grid-margin-x">
<div class="cell">
<label><p>Project Info</p>
<textarea class="textarea" name="field_message" rows="8" placeholder="Project Info" required></textarea>
</label>
</div>
</div><!-- /.grid-x -->
<!-- Submit Button -->
<div class="grid-x">
<fieldset class="cell auto text-center">
<button class="button action-button gradient-f-100" type="submit" value="Submit">Send <i class="fa fa-paper-plane" aria-hidden="true"></i></button>
</fieldset>
</div>
</form>
</div>
</div>
</div>
</section><!-- /.book-appointment -->
}
And here is my PHP:
<?php
$errors = '';
$myemail = 'email#hotmail.com';//
if(empty($_GET['firstname']) ||
empty($_GET['email']) ||
empty($_GET['field_message']))
{
$errors .= "\n Error: all fields are required";
}
$firstname = $_GET['firstname'];
$lastname= $_GET ['lastname'];
$email = $_GET['email'];
$orgname = $_GET['orgname'];
$board = $_GET['board'];
$info = $_GET ['info'];
$budget = $_GET ['budget'];
$field_message = $_GET ['field_message'];
if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*#[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
$email))
{
$errors .= "\n Error: Invalid email address";
}
if( empty($errors))
{
$to = $myemail;
$email_subject = "Form submission: $firstname $lastname";
$email_body = "You have received a new message. ".
" Here are the details:\n Name: $firstname \n Last Name: $lastname \n Email:
$email \n Organization Name: $orgname \n Board: $board \n Organization Info:
$info \n Budget: $budget \n Message \n $field_message";
$headers = "From: $myemail\n";
$headers .= "Reply-To: $email";
mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
include ('Location: contact-form-thank-you.html');
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Contact form handler</title>
</head>
<body>
<!-- This page is displayed only if there is some error -->
<?php
echo nl2br($errors);
?>
</body>
</html>
You have some misnamed variables here (should be $_GET because your form defaults to that method and there are no form fields named 'name' or 'message'), so your error is coming from this block of code:
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['message']))
{
$errors .= "\n Error: all fields are required";
}
I strongly suspect you want the following fields:
if(empty($_GET['firstname']) ||
empty($_GET['email']) ||
empty($_GET['field_message']))
{
$errors .= "\n Error: all fields are required";
}
Your form has no method specified, so it defaults to GET. This means all of your variables will be in the $_GET array, not $_POST
$firstname = $_GET['firstname'];
$lastname= $_GET ['lastname'];
$email = $_GET['email'];
$orgname = $_GET['orgname'];
$board = $_GET['board'];
$info = $_GET ['info'];
$budget = $_GET ['budget'];
$field_message = $_GET ['field_message'];
You can also simplify the following block of code, instead of using complex and possibly inaccurate regex:
if (!filter_var($email, FILTER_VALIDATE_EMAIL))
{
$errors .= "\n Error: Invalid email address";
}
This is not a php issue you are looking in post data so your form needs to submit data in post.
<form method="post" data-abide novalidate>

PHP Contact Form don't respond properly

I'm new to PHP and I've got issue in my contact form. When I press "Submit" in my form it skips (somewhere, I don't know where and why it happens) to other site, and conditions are not checked by the php code. What's more, you can type wrong answer in "human recognizer" and it will still send and email.
I was looking for som bad declarations or wrong syntax, but all seems to be good. I assume that also my contact.php responds properly if it sends an email (but without checking conditions).
I don't know if it's connected but my modal window in it also doesn't want to close (but on the other site the same code works fine, when there is other form withoud "action=contact.php" field).
My main head.php:
<!--HEAD-->
<head>
<title>X</title>
<!--META-->
<meta http-equiv="Content-Type" content="text/html"; charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="SitePoint">
<!--CSS-->
<link id="theme" rel="stylesheet" href="css/light.css">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- Font Awesome -->
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
</head>
<!--END OF HEAD-->
<body>
<script src="https://code.jquery.com/jquery-3.2.1.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.5/jspdf.min.js"></script>
<script src="js/dropdown.js"></script>
<script src="js/scrolling-nav.js"></script>
<script src="js/theme-switch.js"></script>
<script src="js/nav-position.js"></script>
<nav id="mainNav">
<bar>
<i id="hamburger" class="fa fa-bars" aria-hidden="true"></i>
</bar>
<ul id="menu">
<li>Main</li>
<li>Generator</li>
<li>About</li>
<li>Contact</li>
</ul>
</nav>
<section id = "main" >
<div class = "content">
<h1>Hello!</h1>
<p>:)</p>
</div></section>
<section id = "generator">
<div class = "content">
<h1>Generator</h1>
<form id="generator-form" ="form-horizontal" role="form" method="post" action="generator.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" placeholder="First & Last Name" value="<?php echo htmlspecialchars($_POST['name']); ?>">
<?php echo "<p class='text-danger'>$errName</p>";?>
</div>
</div>
<div class="form-group">
<label for="idCardNumber" class="col-sm-2 control-label">Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="idCardNumber" name="idCardNumber" placeholder="Student ID Card Number" value="<?php echo htmlspecialchars($_POST['name']); ?>">
<?php echo "<p class='text-danger'>$errName</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>
</div></section>
<section id = "about">
<div class = "content">
<h1>About</h1>
<p></p>
</div></section>
<section id="contact">
<div class="content">
<h1>Contact</h1>
<p><a class="btn btn-default btn-lg" href="#contact-form">Contact Us</a></p>
<p><iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d5122.204450340393!2d19.91387757798398!3d50.065647167696376!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x47165ba756b59b21%3A0xb20c8dba21b317d1!2sAkademia+G%C3%B3rniczo-Hutnicza+im.+Stanis%C5%82awa+Staszica+w+Krakowie!5e0!3m2!1spl!2spl!4v1511628584066" width="500rem" height="500rem" frameborder="0" style="border:0" allowfullscreen></iframe></p>
</div>
</section>
<footer>
<label class="switch">
<input type="checkbox" onchange=" switchTheme(this)">
<span class="slider"></span>
</label>
<p>Copyright©2017 for </p>
</footer>
<!--SIGN UP-->
<div id="contact-form" class="modal-window">
<div>
Close
<form action="contact.php">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" id="name" name="name" placeholder="First & Last Name" value="<?php echo htmlspecialchars($_POST['name']); ?>">
<p class="text-danger"><?php echo $errName; ?></p>
</div>
<div class="form-group">
<label for="email">Email address</label>
<input type="email" class="form-control" id="email" name="email" placeholder="example#domain.com" value="<?php echo htmlspecialchars($_POST['email']); ?>">
<p class="text-danger"><?php echo $errEmail; ?></p>
</div>
<div class="form-group">
<label for="message">Message</label>
<textarea class="form-control" rows="4" name="message" value="<?php echo htmlspecialchars($_POST['message']);?>"></textarea>
<p class="text-danger"><?php echo $errMessage; ?></p>
</div>
<div class="form-group">
<label for="human">1 + 1 = ?</label>
<input type="text" class="form-control" id="human" name="human" pattern=".{1,}" required title="At least 1 character required" placeholder="Your Answer">
<p class="text-danger"><?php echo $errHuman; ?></p>
</div>
<input id="submit" name="submit" type="submit" value="Send" class="btn btn-primary btn-lg"></input>
<div class="form-group">
<?php echo $result; ?>
</div>
</form>
</div>
</div>
<!--END SIGN UP-->
<!--CONTACT FORM-->
<div id="contact-form" class="modal-window">
<a title="Close" class="modal-close">Close</a>
<form id="contactForm" role="form" method="post" action="contact.php">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" id="name" name="name" pattern=".{3,}" required title="At least 3 characters required" placeholder="First & Last Name" value="<?php echo htmlspecialchars($_POST['name']); ?>">
</div>
<div class="form-group">
<label for="email">Email address</label>
<input type="email" class="form-control" id="email" name="email" placeholder="example#domain.com" pattern=".{3,}" required title="At least 3 characters required" value="<?php echo htmlspecialchars($_POST['email']); ?>">
<?php echo "<p class='text-danger'>$errEmail</p>";?>
</div>
<div class="form-group">
<label for="message">Message</label>
<textarea class="form-control" rows="4" pattern=".{3,}" required title="At least 3 characters required" name="message">
<?php echo htmlspecialchars($_POST['message']);?>
</textarea>
<?php echo "<p class='text-danger'>$errMessage</p>";?>
</div>
<div class="form-group">
<label for="human">1 + 1 = ?</label>
<input type="text" class="form-control" id="human" name="human" pattern=".{1,}" required title="At least 1 character required" placeholder="Your Answer">
<p class='text-danger'>$errHuman</p>
</div>
<input name="submit" type="submit" value="Send" class="btn btn-primary btn-lg">
<div class="form-group">
<?php echo $result; ?>
</div>
</form>
</div>
<!--CONTACT FORM-->
</body>
</html>
My contact.php code:
<?php
if (isset($_POST["submit"])) {
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$human = intval($_POST['human']);
$from = 'Generator Contact';
$to = 'kamykx#gmail.com';
$subject = 'Message from AGH Generator Form';
$body ="From: $name\n E-Mail: $email\n Message:\n $message";
//CHECK NAME
if (!$name || empty($name)) {
$errName = 'Please enter your name';
}
//CHECK EMAIL
if (!$email || !filter_var($email, FILTER_VALIDATE_EMAIL) || empty($email)) {
$errEmail = 'Please enter a valid email address';
}
//CHECK MESSAGE
if (!$message || empty($message)) {
$errMessage = 'Please enter your message';
}
//CHECK IF USER IS NOT A BOT
if ($human !== 2 || $human !=2) {
$errHuman = 'Please... proof that you are not a bot :>';
}
//SEND THE EMAIL IF THERE ARE NO EXISTING ERRORS
if (!empty($errName) && !empty($errEmail) && !empty($errMessage) && !empty($errHuman)) {
if (mail ($to, $subject, $body, $from)) {
$result='<div class="alert alert-success">Thank You! We 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>';
}
header("Location: home.php");
}
}
?>
EDIT:
I've done improvements in my php code (there was logical problem in line error fields are empty: was -> if(!empty($errName)) but should be -> if(empty($errName)).
But I've still got and issue. I've compressed the code in order to stay on the same page after contact form submit, but when we click the "submit" button nothing appears (no errors are displayed), page only refreshes and open the form again. What's wrong now? NEW CODE:
<!DOCTYPE HTML>
<html lang="en">
<!--HEAD-->
<head>
<title>AGH Application for entry with ECTS deficit generator</title>
<!--META-->
<meta http-equiv="Content-Type" content="text/html"; charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="SitePoint">
<meta name="Description" content="It is simple PDF generator for sing with lack of ECTS for another term" />
<meta name="Keywords" content="ECTS, deficit, deficyt, Poland, Cracow, generator, application, form, pdf, AGH, UST, Akademia, Górniczko, Hutnicza, University, S cience, Technology, Polska, Kraków, " />
<!--CSS-->
<link id="theme" rel="stylesheet" href="css/dark.css">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- Font Awesome -->
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
</head>
<!--END OF HEAD-->
<body>
<script src="https://code.jquery.com/jquery-3.2.1.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.5/jspdf.min.js"></script>
<script src="js/dropdown.js"></script>
<script src="js/scrolling-nav.js"></script>
<script src="js/theme-switch.js"></script>
<script src="js/nav-position.js"></script>
<nav id="mainNav">
<bar>
<i id="hamburger" class="fa fa-bars" aria-hidden="true"></i>
</bar>
<ul id="menu">
<li>Main</li>
<li>Generator</li>
<li>About</li>
<li>Contact</li>
</ul>
</nav>
<section id = "main" >
<div class = "content">
<h1>Hello!</h1>
<p>Welocome to The AGH Application for entry with ECTS deficit generator website. We hope that you use it just for fun :)</p>
</div></section>
<section id = "generator">
<div class = "content">
<h1>Generator</h1>
</div></section>
<section id = "about">
<div class = "content">
<h1>About</h1>
<p>This webapge was created as a project for the Web Technologies. The main reason why it exists is that very common among Students is that they want to apply for entry on another term with ECTS deficit. This site will help students and AGH employees by generating PDF application. We hope that everything at AGH will be fast and growing in the future. We want to make our students life BETTER! </p>
</div></section>
<section id="contact">
<div class="content">
<h1>Contact</h1>
<p><a class="btn btn-default btn-lg" href="#contact-form">Contact Us</a></p>
<?php echo $result; ?>
<p><iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d5122.204450340393!2d19.91387757798398!3d50.065647167696376!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x47165ba756b59b21%3A0xb20c8dba21b317d1!2sAkademia+G%C3%B3rniczo-Hutnicza+im.+Stanis%C5%82awa+Staszica+w+Krakowie!5e0!3m2!1spl!2spl!4v1511628584066" width="500rem" height="500rem" frameborder="0" style="border:0" allowfullscreen></iframe></p>
</div>
</section>
<footer>
<label class="switch">
<input type="checkbox" onchange=" switchTheme(this)">
<span class="slider"></span>
</label>
<p>Copyright©2017 Marcin Kamiński for AGH </p>
</footer>
<!--SIGN UP-->
<?php
if (isset($_POST["send"])) {
$name = $_POST['name']; //Getting variable from form
$email = $_POST['email']; //Getting variable from form
$message = $_POST['message']; //Getting variable from form
$human = intval($_POST['human']); //Getting variable from form
$from = 'Generator Contact'; //Set sender
$to = 'kamykx#gmail.com'; //Where to send an email
$subject = 'Message from AGH Generator Form'; //Set the subject of email
$errName = $errEmail = $errMessage = $errHuman = ''; //Values of errors
$body ="From: $name\n E-Mail: $email\n Message:\n $message"; //Body of email
//CHECK NAME
if (empty($name)) {
$errName = 'Please enter your name';
}
//CHECK EMAIL
if (!filter_var($email, FILTER_VALIDATE_EMAIL) || empty($email)) {
$errEmail = 'Please enter a valid email address';
}
//CHECK MESSAGE
if (empty($message)) {
$errMessage = 'Please enter your message';
}
//CHECK IF USER IS NOT A BOT
if ($human !== 2 || $human !=2) {
$errHuman = 'Please... proof that you are not a bot :>';
}
//SEND THE EMAIL IF THERE ARE NO EXISTING ERRORS
if (empty($errName) && empty($errEmail) && empty($errMessage) && empty($errHuman)) {
if (mail($to, $subject, $body, $from)) {
$result = '<div class="alert alert-success">Thank You! We 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>';
}
}
}
?>
<div id="contact-form" class="modal-window">
<div>
Close
<form id="contactForm" role="form" method="post">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" id="name" name="name" placeholder="First & Last Name" value="<?php echo htmlspecialchars($_POST['name']); ?>">
<p class="text-danger"><?php echo $errName; ?></p>
</div>
<div class="form-group">
<label for="email">Email address</label>
<input type="email" class="form-control" id="email" name="email" placeholder="example#domain.com" value="<?php echo htmlspecialchars($_POST['email']); ?>">
<p class="text-danger"><?php echo $errEmail; ?></p>
</div>
<div class="form-group">
<label for="message">Message</label>
<textarea class="form-control" rows="4" name="message" value="<?php echo htmlspecialchars($_POST['message']);?>"></textarea>
<p class="text-danger"><?php echo $errMessage; ?></p>
</div>
<div class="form-group">
<label for="human">1 + 1 = ?</label>
<input type="text" class="form-control" id="human" name="human" placeholder="Your Answer">
<p class="text-danger"><?php echo $errHuman; ?></p>
</div>
<button id="send" name="send" type="submit" value="Send" class="btn btn-default btn-lg">Send</button>
</form>
</div>
</div>
<!--END SIGN UP-->
</body>
</html>
Your issue is in the logic of this line:
if (!empty($errName) && !empty($errEmail) && !empty($errMessage) && !empty($errHuman)) {
Basically this is saying if everything is wrong, send the email. The not empty check means that there was an error and the variable now holds the error string.
Instead, you just need to create the variables as an empty string and check if they are still empty:
$errName = $errEmail = $errMessage = $errHuman = '';
// CHECK NAME... etc... all the checks
if (empty($errName) && empty($errEmail) && empty($errMessage) && empty($errHuman)) {
However, you're not displaying the error to the user, and you're ending up with a bunch of loose variables. I recommend a slightly different approach using an array of errors...
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
$errors = [];
//CHECK NAME
if (!$name || empty($name)) {
$errors['name'] = 'Please enter your name';
}
//CHECK EMAIL
if (!$email || !filter_var($email, FILTER_VALIDATE_EMAIL) || empty($email)) {
$errors['email'] = 'Please enter a valid email address';
}
//etc...
if (empty($errors)) {
//send email
} else {
$result = '<div class="alert alert-danger">Sorry there was an error sending your message:<br>';
foreach ($errors as $key => $error) {
$result .= $error . '<br>';
}
$result .= '</div>';
}
However, if you immediately call a header function after this, the user will never see the error or get a chance to fix it. You can use a query string to send errors back to head.php and display them.
(FYI, the action of a form sends all the POST data to that file, and if there is no action specified, then the form posts to itself.)

post/redirect/get - how to unset session variables

Bellow is part of the code from register.php
if($_SERVER['REQUEST_METHOD'] == "POST") {
/* running some checks of an input*/
if(sizeof($errorArray)==0) {
// redirecting to avoid form resubmission
$_SESSION['registered'] = true;
header('location: success.php',true,303);
}
else{
$_SESSION['post']['email'] = $_POST['email'];
$_SESSION['post']['name'] = $_POST['name'];
$_SESSION['errorArray'] = $errorArray;
header('location: register.php',true,303);
}
}
Logic is simple -- if an errorArray is empty redirect to a success page, else redirect to register.php itself. To avoid form resubmission i tried to put post variables into session variable, so the user doesn't have to fill form again in case of error.
<?php
if (isset($_SESSION['errorArray'])) {
if (sizeof($_SESSION['errorArray']) != 0) {
echo '<div class="alert alert-danger" role="alert">
<h4>There were errors in Your input:</h4>';
foreach ($_SESSION['errorArray'] as $item) {
echo $item . '<br>';
}
}
$_SESSION['post'] = null;
$_SESSION['errorArray'] = null;
}
?>
This part of a code is executed later in register.php but it doesen't gives me the result I want. Somehow the variables are sett to null before the loop above is executed (??!). I have found a solution with get method that includes microtime in url passed to header , but it seams to me that there is more elegant solution that does not every time adds new values to a session variable.
Is there some way around this?
edit :
<?php
session_start();
if ($_SERVER['REQUEST_METHOD'] == "POST") {
// array to hold all the errors of input
$errorArray = [];
$emailRegex = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*#[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/';
$nameRegex = '/^[a-z0-9][a-z0-9_]*[a-z0-9]$/';
$passwordRegex = '/^[a-z0-9][-a-z0-9_!##$?]*[a-z0-9]$/';
$email = $_POST['email'];
if (empty($email)) {
array_push($errorArray, "E-mail field required");
} else {
if (!preg_match($emailRegex, $email)) array_push($errorArray, 'Invalid email');
}
$name = $_POST['name'];
if (empty($name)) {
array_push($errorArray, "Name field required");
} else {
if (!preg_match($nameRegex, $name)) array_push($errorArray, 'Invalid name');
}
$password = $_POST['password'];
$passwordR = $_POST['passwordR'];
if (empty($passwordR) || empty($password)) {
array_push($errorArray, 'Password fields required');
} else if (!preg_match($passwordRegex, $password)) {
array_push($errorArray, 'Invalid password');
} else {
if ($password !== $passwordR) {
array_push($errorArray, 'Password inputs are not the same');
}
}
if (sizeof($errorArray) == 0) {
// redirecting to avoid form resubmission
$_SESSION['registered'] = true;
header('location: success.php', true, 303);
} else {
$_SESSION['post']['email'] = $_POST['email'];
$_SESSION['post']['name'] = $_POST['name'];
$_SESSION['errorArray'] = $errorArray;
header('location: register.php', true, 303);
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Log</title>
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="css/maincss.css" type="text/css">
<meta name="viewport" content="width = device-width, initial-scale = 1, user - scalable = no">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed">
<div class="container">
Home
<ul class="navbar-brand col-xs-5"><?= (isset($username)) ? 'Welcome ' . $username : ''; ?></ul>
Login
Register
</div>
</nav>
<div class="container">
<form class="form-signin" action="register.php" method="post">
<h2 class="form-signin-heading text-center text-capitalize">Registration form</h2>
<!-- I have purposely excluded required attribute from inputs and set type="text"
for an email so all the checks could be done on server side -->
<div class="row center-block">
<div class="col-xs-4"></div>
<div class="col-xs-4">
<label for="email" class="sr-only">Email address</label>
<input type="text" id="email" name="email" class="form-control" placeholder="Email address"
value="<?= (isset($_SESSION['post']['email'])) ? $_SESSION['post']['email'] : ''; ?>" autofocus>
</div>
<div class="col-xs-4"></div>
</div>
<br>
<div class="row center-block">
<div class="col-xs-4"></div>
<div class="col-xs-4">
<label for="name" class="sr-only">Name</label>
<input type="text" id="name" name="name" class="form-control" placeholder="Name"
value="<?= (isset($_SESSION['post']['name'])) ? $_SESSION['post']['name'] : ''; ?>" autofocus>
</div>
<div class="col-xs-4"></div>
</div>
<br>
<div class="row center-block">
<div class="col-xs-4"></div>
<div class="col-xs-4">
<label for="password" class="sr-only">Password</label>
<input type="password" id="password" name="password" class="form-control" placeholder="Password">
</div>
<div class="col-xs-4"></div>
</div>
<br>
<div class="row center-block">
<div class="col-xs-4"></div>
<div class="col-xs-4">
<label for="passwordR" class="sr-only">Repeat Password</label>
<input type="password" id="passwordR" name="passwordR" class="form-control"
placeholder="Repeat Password">
</div>
<div class="col-xs-4"></div>
</div>
<br>
<div class="row">
<div class="col-xs-4"></div>
<div class="col-xs-4 center-block">
<button class="btn btn-lg btn-primary btn-block" type="submit">Submit</button>
</div>
<div class="col-xs-4"></div>
</div>
<br>
<div>
<?php
if (isset($_SESSION['errorArray'])) {
if (sizeof($_SESSION['errorArray']) != 0) {
echo '<div class="alert alert-danger" role="alert">
<h4>There were errors in Your input:</h4>';
foreach ($_SESSION['errorArray'] as $item) {
echo $item . '<br>';
}
}
// $_SESSION['post'] = null;
// $_SESSION['errorArray'] = null;
}
?>
</div>
</form>
</body>
</html>

Blank display when I click submit button from the form

I create form which contain text fields and upload file(register.php), and I want to send data to sendData.php and redirect to payment.php in order user to make payment for document review. I don't know where am wrong from sendData.php, I try to submit data from register.php to sendData and output is blank no error found, I try to check mysql error also no error found.
Page contain Form data
<?php
$errors = "";
if(isset($_GET["error"])){
if($_GET["error"] === "pwd"){
$errors = '<div class="alert alert-danger col-md-3><span class="glyphicon glyphiocn-remove-circle"></span> Passowrd dismatch, please try again</div>';
}
if($_GET["error"] === "undefined"){
$errors = '<div class="alert alert-danger col-md-3><span class="glyphicon glyphiocn-remove-circle"></span> File format dismatch, please try again</div>';
}
if($_GET["error"] === "found_file"){
$errors = '<div class="alert alert-danger col-md-3><span class="glyphicon glyphiocn-remove-circle"></span> Document found error, please try again</div>';
}
}
?>
<!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">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">
<title>CentralAcademy: Register</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="css/bootstrap-theme.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link rel="stylesheet" href="css/jumbtron.css">
<link href="css/custom-file.css" rel="stylesheet">
<style type="text/css">
body{ padding-top: 80px; }
</style>
</head>
<body>
<?php require_once("includes/header.php"); ?>
<div class="container">
<div class="row">
<div class="col-lg-3 breadcrumb">
<h3 class="page-header">Payment</h3>
<p><img src="images/images.png" class="img img-responsive" width="70" height="50" style="display: block; float: left; padding-right:10px;"/> (+255)755-555-555</p><br>
<p><img src="images/airtelM.fw.png" class="img img-responsive" width="70" height="50" style="display: block; float: left; padding-right:10px;"/> (+255)685-555-555</p><br>
<p><img src="images/tigopesa.png" class="img img-responsive" width="70" height="50" style="display: block; float: left; padding-right:10px;"/> (+255)655-555-555</p><br>
</div>
<div class="col-lg-2"></div>
<div class="col-lg-7 breadcrumb">
<?php print $errors; ?>
<h3 class="page-header">Request for Document Review</h3>
<h5><font color="#FF0000">***</font> Please fill all fields required</h5><br>
<form action="sendData.php" method="post" enctype="multipart/form-data" class="form-horizontal">
<div class="form-group">
<div class="col-md-6">
<input name="fname" type="text" placeholder="Enter your FirstName" value="<?php echo isset($_POST['fname']) ? $_POST['fname'] : '' ?>" class="form-control" required id="fname">
</div>
</div>
<div class="form-group">
<div class="col-md-6">
<input name="sname" type="text" class="form-control" value="<?php echo isset($_POST['sname']) ? $_POST['sname'] : '' ?>" placeholder="Enter your LastName" required id="sname">
</div>
</div>
<div class="form-group">
<div class="col-md-6">
<input name="gender" type="radio" class="radio-inline" value="F" checked="CHECKED" required/>Female <input type="radio" name="gender" class="radio-inline" value="M" required/>Male</div>
</div>
<div class="form-group">
<div class="col-md-6">
<input name="email" type="text" class="form-control" value="<?php echo isset($_POST['email']) ? $_POST['email'] : '' ?>" placeholder="Enter your Email Address" required id="email">
</div>
</div>
<div class="form-group">
<div class="col-md-6">
<input name="phone" type="text" class="form-control" placeholder="Enter your Phone Number" value="<?php echo isset($_POST['phone']) ? $_POST['phone'] : '' ?>" maxlength="13" required id="phone" pattern="[\+]\d{3}\d{3}\d{6}">
</div>
</div>
<div class="form-group">
<div class="col-md-6">
<input type="radio" name="edlevel" value="bachelor" class="radio-inline" checked="CHECKED" required/>Bachelor
<input type="radio" name="edlevel" value="Post Graduate" class="radio-inline" />Post Grad
<input name="edlevel" type="radio" value="Masters" class="radio-inline" />Masters
<input name="edlevel" type="radio" value="PhD" class="radio-inline" />PhD
</div>
</div>
<div class="form-group">
<div class="col-md-6">
<input name="affi" type="text" class="form-control" value="<?php echo isset($_POST['affi']) ? $_POST['affi'] : '' ?>" placeholder="Enter organisation/College/University" required>
</div>
</div>
<div class="form-group">
<div class="col-md-6">
<input name="title" type="text" class="form-control" value="<?php echo isset($_POST['title']) ? $_POST['title'] : '' ?>" placeholder="Enter your document title" required>
</div>
</div>
<div class="form-group">
<div class="col-md-6 fileUpload">
<input type="file" name="files" id="file"/>
</div>
</div>
<div class="form-group">
<div class="col-md-6">
<input name="password" type="password" class="form-control" placeholder="Choose Your Password" required>
</div>
</div>
<div class="form-group">
<div class="col-md-6">
<input name="password2" type="password" class="form-control" placeholder="Confirm Your Password" required>
</div>
</div>
<br>
<div class="form-group">
<div class="col-md-6">
<button name="Register" type="submit" class="btn btn-info"><span class="glyphicon glyphicon-user"></span> Register Now</button><br><br>
<p>If you are already registered please click here</p>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="container marketing">
<!-- START THE FEATURETTES -->
<?php require_once("includes/footer.php"); ?>
</div><!-- /.container -->
<script type="text/javascript" src="js/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/main.js"></script>
</body>
</html>
//sendData.php
<?php
if(isset($_FILES['files']) && $_POST["password"] === $_POST["password2"]){
session_start();
require_once("includes/dbconnect.php");
$fname = $_POST["fname"];
$sname = $_POST["sname"];
$email = $_POST["email"];
$phone = $_POST["phone"];
$title = $_POST["title"];
$password = $_POST["password"];
$gender = $_POST["gender"];
$edlevel = $_POST["edlevel"];
$affi = $_POST["affi"];
//Keep all author data to session variable
$_SESSION["fname"] = $fname;
$_SESSION["sname"] = $sname;
$_SESSION["email"] = $email;
$_SESSION["phone"] = $email;
$_SESSION["passwprd"] = $password;
$_SESSION["gender"] = $gender;
$_SESSION["edlevel"] = $edlevel;
$_SESSION["affi"] = $affi;
$errors= array();
$extensions = array("docx");
$file_name = rand(1000,100000)."-".$_FILES['files']['name'];
$file_size = $_FILES['files']['size'];
$file_tmp = $_FILES['files']['tmp_name'];
$file_type = $_FILES['files']['type'];
$file_ext = strtolower(substr($_FILES['files']['name'],strrpos($_FILES['files']['name'],'.')+1));
if(in_array($file_ext,$extensions ) === true && $file_size < 2097152){
$result = $connect->query("INSERT INTO temp VALUES(NULL,'$title',$email','$file_name',now())");
if($result){
$desired_dir="AuthorReport";
if(empty($errors)===true){
if(is_dir($desired_dir)===false){
mkdir("$desired_dir", 0700); // Create directory if it does not exist
}
if(is_dir("$desired_dir/".$file_name)==false){
move_uploaded_file($file_tmp,"$desired_dir/".$file_name);
}else{ // rename the file if another one exist
$new_dir="$desired_dir/".$file_name.time();
rename($file_tmp,$new_dir) ;
}
header("location: payment.php");
exit();
}
else{ header("location:register.php?error=found_file"); exit(); }
}
}
else{ header("location:register.php?error=undefined"); exit(); }
}
else{ header("location:register.php?error=pwd"); exit(); }
?>
$email doesn't have start quote
$result = $connect->query("INSERT INTO temp VALUES(NULL,'$title',$email','$file_name',now())");
that's why you have the error.
and to be sure where are you entering these values exactly where you want use add also the column names in INSERT statement
$result = $connect->query("INSERT INTO temp
(column_title, column_email, column_filename, thedate)
VALUES
('$title','$email','$file_name',NOW() )" );

form does not send mail

I have started to make a message box, where a user can send a message to me. When I run the code the boxes is working fine, but I never receive a mail, and I do not get any errors. Can anybody see if I am doing something totally wrong?
<?php
//set validation error flag as false
$error = false;
//check if form is submitted
if (isset($_POST['submit']))
{
$name = trim($_POST['txt_name']);
$fromemail = trim($_POST['txt_email']);
$subject = trim($_POST['txt_subject']);
$message = trim($_POST['txt_msg']);
//name can contain only alpha characters and space
if (!preg_match("/^[a-zA-Z ]+$/",$name))
{
$error = true;
$name_error = "Please Enter Valid Name";
}
if(!filter_var($fromemail,FILTER_VALIDATE_EMAIL))
{
$error = true;
$fromemail_error = "Please Enter Valid Email ID";
}
if(empty($subject))
{
$error = true;
$subject_error = "Please Enter Your Subject";
}
if(empty($message))
{
$error = true;
$message_error = "Please Enter Your Message";
}
if (!$error)
{
//send mail
$toemail = "test#stackoverflow.com";
$subject = "Enquiry from Visitor " . $name;
$body = "Here goes your Message Details: \n\n Name: $name \n From: $fromemail \n Message: \n $message";
$headers = "From: $fromemail\n";
$headers .= "Reply-To: $fromemail";
if (mail ($toemail, $subject, $body, $headers))
$alertmsg = '<div class="alert alert-success text-center">Message sent successfully. We will get back to you shortly!</div>';
else
$alertmsg = '<div class="alert alert-danger text-center">There is error in sending mail. Please try again later.</div>';
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap 3 Contact Form Example</title>
<meta content="width=device-width, initial-scale=1.0" name="viewport" >
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" />
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3 well">
<form role="form" class="form-horizontal" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="contactform">
<fieldset>
<legend>Bootstrap Contact Form</legend>
<div class="form-group">
<div class="col-md-12">
<label for="txt_name" class="control-label">Name</label>
</div>
<div class="col-md-12">
<input class="form-control" name="txt_name" placeholder="Your Full Name" type="text" value="<?php if($error) echo $name; ?>" />
<span class="text-danger"><?php if (isset($name_error)) echo $name_error; ?></span>
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<label for="txt_email" class="control-label">Email ID</label>
</div>
<div class="col-md-12">
<input class="form-control" name="txt_email" placeholder="Your Email ID" type="text" value="<?php if($error) echo $fromemail; ?>" />
<span class="text-danger"><?php if (isset($fromemail_error)) echo $fromemail_error; ?></span>
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<label for="txt_subject" class="control-label">Subject</label>
</div>
<div class="col-md-12">
<input class="form-control" name="txt_subject" placeholder="Your Subject" type="text" value="<?php if($error) echo $subject; ?>" />
<span class="text-danger"><?php if (isset($subject_error)) echo $subject_error; ?></span>
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<label for="txt_msg" class="control-label">Message</label>
</div>
<div class="col-md-12">
<textarea class="form-control" name="txt_msg" rows="4" placeholder="Your Message"><?php if($error) echo $message; ?></textarea>
<span class="text-danger"><?php if (isset($message_error)) echo $message_error; ?></span>
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<input name="submit" type="submit" class="btn btn-primary" value="Send" />
</div>
</div>
</fieldset>
</form>
<?php if (isset($alertmsg)) { echo $alertmsg; } ?>
</div>
</div>
</div>
</body>
</html>

Categories