Php Registration form doesn't work - php

I have created a registration form using php, but it doesn't work, and it doesn't show any errors.
register.html
<!DOCTYPE html>
<head>
<title>abc</title>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-5 col-md-offset-4">
<div class="panel panel-default">
<div class="panel-heading"> <strong class="login">Sign Up</strong>
</div>
<div class="panel-body">
<form class="form-horizontal" role="form" name="registration" method="post" action="registration.php">
<!--first name-->
<div class="form-group">
<label for="fname" class="col-sm-3 control-label">First Name</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="fname" name="fname" placeholder=" First Name" required="">
</div>
</div>
<!--/first name-->
<!--last name-->
<div class="form-group" >
<label for="lname" class="col-sm-3 control-label">Last Name</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="lname" placeholder=" Last Name" required="">
</div>
</div>
<!--/last name-->
<!--email-->
<div class="form-group">
<label for="email" class="col-sm-3 control-label">Email</label>
<div class="col-sm-9">
<input type="email" class="form-control" id="email" name="email" placeholder="Email" required="">
</div>
</div>
<!--email-->
<!--Gender-->
<div class="form-inline form-group">
<label class=" col-sm-3 control-label"> Gender</label>
<label class="male">
<input value="male" type="radio" id="gender" name="male">Male
</label>
<label class="female">
<input value="female" type="radio" id="gender" name="male">Female
</label>
</div>
<!--/gender-->
<!--address-->
<div class="form-group">
<label for="address" class="col-sm-3 control-label">Address</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="address" name="address" placeholder=" Address" required="">
</div>
</div>
<!--/address-->
<!--telno-->
<div class="form-group">
<label for="telno" class="col-sm-3 control-label">Contact No</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="telno" placeholder=" Contact No" required="">
</div>
</div>
<!--/telno-->
<!--password-->
<div class="form-group">
<label for="password" class="col-sm-3 control-label">Password</label>
<div class="col-sm-9">
<input type="password" class="form-control" id="password" name="password" placeholder="Password" required="">
</div>
</div>
<!--password-->
<!--password-->
<div class="form-group">
<label for="repassword" class="col-sm-3 control-label">Re-enter Password</label>
<div class="col-sm-9">
<input type="password" class="form-control" id="repassword" name="repassword" placeholder="Re-enter Password" required="">
</div>
</div>
<!--password-->
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<div class="checkbox">
<label class="">
<input type="checkbox" class="">Remember me</label> forget password
</div>
</div>
</div>
<div class="form-group last">
<div class="col-sm-offset-3 col-sm-9">
<button type="submit" class="btn btn-warning btn-sm">Sign Up</button>
<button type="reset" class="btn btn-default btn-sm">Reset</button>
</div>
</div>
</form>
</div>
<div class="panel-footer">If you are already Registered? LogIn here
</div>
</div>
</div>
</div>
</div>
</body>
</html>
this is the registration.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php //start php tag
//include config.php page for database connection
Include('config.php');
//if submit is not blanked i.e. it is clicked.
If(isset($_REQUEST['submit'])!='')
{
If($_REQUEST['fname']=='' || $_REQUEST['email']=='' || $_REQUEST['password']==''|| $_REQUEST['repassword']=='')
{
Echo "please fill the empty field.";
}
Else
{
$sql="insert into user(firstname,email,password) values('".$_REQUEST['fname']."', '".$_REQUEST['email']."', '".$_REQUEST['password']."')";
$res=mysql_query($sql);
If($res)
{
Echo "Record successfully inserted";
}
Else
{
Echo "There is some problem in inserting record";
}
}
}
?>
</body>
</html>
this is the config.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$hostname="localhost"; //local server name default localhost
$username="root"; //mysql username default is root.
$password=""; //blank if no password is set for mysql.
$database="rcjcompany"; //database name which you created
$con=mysql_connect($hostname,$username,$password);
if(! $con)
{
die('Connection Failed'.mysql_error());
}
mysql_select_db($database,$con);
?>
</body>
</html>
this is the sql for database
Create database student;
use student;
create table student(id int,name varchar(40),email varchar(80),password varchar(40));

The first if seems useless as long as you don't have any field named "submit". I used your code and debug with firefox and you can see there is no field called submit sent to server:
Try to remove the first if or add an else condition so at least you get any print.

Related

As new to php i am not clear over the jumps betveen php-pages. My code below. is this the right way?

I want to se available dates in a dropdown - done
After i´v choosen the date i want to see the available time - done
The customer should be able to book the choosen timeslot - I think i knowe this one, work in progress.
Problem: I want the customer to se the dropdown and the result in the same page and maybe change it when the time comes visably. I´v been playing around with action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" but thats not it i belive.
I am a bit lost in best practice regarding files and jumps betveen them. I have separated the php and html code in different pages. When i´m ready i lift the php-files to includes folder offcourse.
HTML - form with dropdown and submit
php - fill dropdown with dates
html - form with result text fields
php - code for result (timeslot data)
form_date.php
<?PHP
require_once('booking_available_dates.php');
?>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<form name='date_registration' action='booking_available_dates.php' method='POST'>
<div class="form-group row">
<label for="select" class="col-2 col-form-label">Hämta första lediga tid för valt datum</label>
<div class="col-10">
<select id="date_input" name="date_input" class="custom-select">
<?php foreach ($dates as $row): ?>
<option><?=$row["date_booking_customer"]?></option>
<?php endforeach ?>
</select>
</div>
</div>
<div class="form-group row">
<div class="offset-4 col-8">
<button name="submit" type="submit" class="btn btn-primary">Hämta tid!</button>
</div>
</div>
</form>
booking_available_dates.php
<?php
require_once('dbhandler.php');
$dbh = new DBHandler();
if ($dbh->getInstance() === null) {
die("No database connection");
}
try {
$sql = "CALL `booking_dates_available`();";
$stmt = $dbh->getInstance()->prepare($sql);
$stmt->execute();
$dates=$stmt->fetchAll();
}
catch(PDOException $e) {
echo ($e->getMessage());
}
?>
booking_confirm_view.php (not ready - work in progress)
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<form>
<div class="form-group row">
<label for="date" class="col-4 col-form-label">Datum</label>
<div class="col-8">
<input id="date" readonly="readonly" name="date" type="text" class="form-control">
</div>
</div>
<div class="form-group row">
<label for="time" class="col-4 col-form-label">Tid</label>
<div class="col-8">
<input id="time" readonly="readonly" name="time" type="text" class="form-control">
</div>
</div>
<div class="form-group row">
<label for="owner" class="col-4 col-form-label">Båtägare</label>
<div class="col-8">
<input id="owner" name="owner" type="text" class="form-control" required="required">
</div>
</div>
<div class="form-group row">
<label class="col-4">Medlem i HSS?</label>
<div class="col-8">
<div class="custom-control custom-radio custom-control-inline">
<input name="member" id="member_0" type="radio" required="required" class="custom-control-input" value="thru">
<label for="member_0" class="custom-control-label">Medlem</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input name="member" id="member_1" type="radio" required="required" class="custom-control-input" value="false">
<label for="member_1" class="custom-control-label">Ej medlem</label>
</div>
</div>
</div>
<div class="form-group row">
<label for="boatname" class="col-4 col-form-label">Båtnamn</label>
<div class="col-8">
<input id="boatname" name="boatname" type="text" class="form-control">
</div>
</div>
<div class="form-group row">
<label for="email" class="col-4 col-form-label">E-post</label>
<div class="col-8">
<input id="email" name="email" type="text" class="form-control" required="required">
</div>
</div>
<div class="form-group row">
<label for="mobile" class="col-4 col-form-label">Mobilnummer</label>
<div class="col-8">
<input id="mobile" name="mobile" type="text" class="form-control" required="required">
</div>
</div>
<div class="form-group row">
<div class="offset-4 col-8">
<button name="submit" type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</form>
booking_available_time.php
<?php
require_once('dbhandler.php');
$dbh = new DBHandler();
if ($dbh->getInstance() === null) {
die("No database connection");
}
try {
$sql = "CALL `booking_date_input` (:date_input);";
$stmt = $dbh->getInstance()->prepare($sql);
$stmt->bindParam(':date_input', $date_input, PDO::PARAM_STR);
$date_input = $_POST["date_input"];
$stmt->execute();
$result=$stmt->fetchAll();
}
catch(PDOException $e) {
echo ($e->getMessage());
}
?>
$result is the array with the timeslot data.

PHP form submission error

I created new inquiry form for my website. But it's giving the following error message.
Error
Sorry there was an error sending your form.
mail:Could not instantiate mail function.
Form HTML:
<!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">
<title>PHP Contact Form Script With Validation - reusable form</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" >
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" >
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<link rel="stylesheet" href="form.css" >
<script src="form.js"></script>
</head>
<body >
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<h2>Contact Us</h2>
<p> Send us your message and we will get back to you as soon as possible </p>
<form role="form" method="post" id="reused_form">
<div class="row">
<div class="col-sm-6 form-group">
<label for="name"> First Name:</label>
<input type="text" class="form-control" id="firstname" name="firstname" maxlength="50">
</div>
<div class="col-sm-6 form-group">
<label for="name"> Last Name:</label>
<input type="text" class="form-control" id="lastname" name="lastname" maxlength="50">
</div>
</div>
<div class="row">
<div class="col-sm-6 form-group">
<label for="email"> Email:</label>
<input type="text" class="form-control" id="email" name="email" maxlength="50">
</div>
<div class="col-sm-6 form-group">
<label for="email"> Phone:</label>
<input type="tel" class="form-control" id="phone" name="phone" required maxlength="50">
</div>
</div>
<div class="row">
<div class="col-sm-12 form-group">
<label for="name"> Message:</label>
<textarea class="form-control" type="textarea" id="message" name="message" placeholder="Your Message Here" maxlength="6000" rows="7"></textarea>
</div>
</div>
<div class="row">
<div class="col-sm-12 form-group">
<button type="submit" class="btn btn-lg btn-success btn-block" id="btnContactUs">Post It! </button>
</div>
</div>
</form>
<div id="success_message" style="width:100%; height:100%; display:none; "> <h3>Sent your message successfully!</h3> </div>
<div id="error_message" style="width:100%; height:100%; display:none; "> <h3>Error</h3> Sorry there was an error sending your form. </div>
</div>
</div>
</div>
</body>
</html>
Handler.php:
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
/*
Tested working with PHP5.4 and above (including PHP 7 )
*/
require_once './vendor/autoload.php';
use FormGuide\Handlx\FormHandler;
$pp = new FormHandler();
$validator = $pp->getValidator();
$validator->fields(['firstname','lastname', 'email','phone'])->areRequired()->maxLength(50);
$validator->field('email')->isEmail();
$validator->field('message')->maxLength(6000);
$pp->sendEmailTo('name#mail.com'); // ← Your email here
echo $pp->process($_POST);
You are not defining an action for the form.
<form role="form" method="post" id="reused_form" action="Handler.php">
<!-- html goes here -->
</form>

php error and even after defining variable

this is my block of code for insert product of my project
<?php
include('includes/db.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
<html lang="EN">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="shortcut icon" href="images/logo.jpg" type="image/x-icon" />
<title>Insert Products</title>
<script src="https://cloud.tinymce.com/stable/tinymce.min.js"></script>
<script>tinymce.init({ selector:'textarea' });</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="fontawesome/css/font-awesome.min.css" />
</head>
<body>
<div class="row">
<div class="col-lg-12">
<ol class="breadcrumb">
<li class="active"><i class="fa fa-dashboard"></i>Dashboard/Insert Products</li>
</ol> <!--breadcrumb ends here-->
</div> <!---col-lg-12 ends-->
</div> <!--row ends-->
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<i class="fa fa-money fa-fw"></i> Insert Products
</h3>
</div> <!--panel heading ends--->
<div class="panel-body">
<form class="form-horizontal" method="post" enctype="multipart/form-data">
<div class="form-group">
<label class="col-md-3 control-label" >Product title</label>
<div class="col-md-6">
<input type="text" name="product_title" class="form-control" required>
</div>
</div> <!---form-group-->
<div class="form-group">
<label class="col-md-3 control-label" >Product Category</label>
<div class="col-md-6">
<select name="product_cat" class="form-control" required>
<option>Select Category</option>
<?php
$get_p_cats="select * from product_categories";
$run_p_cats=mysqli_query($conn,$get_p_cats);
while($row_p_cats=mysqli_fetch_array($run_p_cats)){
$p_cat_id=$row_p_cats['p_cat_id'];
$p_cat_title=$row_p_cats['p_cat_title'];
echo "<option value='$p_cat_id'>$p_cat_title</option>";
}
?>
</select>
</div>
</div> <!---form-group-->
<div class="form-group">
<label class="col-md-3 control-label" >Category</label>
<div class="col-md-6">
<select name="cat" class="form-control" required>
<option>Select Category</option>
<?php
$get_cat="select * from categories";
$run_cat=mysqli_query($conn,$get_cat);
while($row_cat=mysqli_fetch_array($run_cat)){
$cat_id=$row_cat['cat_id'];
$cat_title=$row_cat['cat_title'];
echo "<option value='$cat_id'>$cat_title</option>";
}
?>
</select>
</div>
</div> <!---form-group-->
<div class="form-group">
<label class="col-md-3 control-label" >Product Image 1</label>
<div class="col-md-6">
<input type="file" name="product_img1" class="form-control" required>
</div>
</div> <!---form-group-->
<div class="form-group">
<label class="col-md-3 control-label" >Product Image 2</label>
<div class="col-md-6">
<input type="file" name="product_img2" class="form-control" required>
</div>
</div> <!---form-group-->
<div class="form-group">
<label class="col-md-3 control-label" >Product Image 3</label>
<div class="col-md-6">
<input type="file" name="product_img3" class="form-control" required>
</div>
</div> <!---form-group-->
<div class="form-group">
<label class="col-md-3 control-label" >Product Price</label>
<div class="col-md-6">
<input type="text" name="product_price" class="form-control" required>
</div>
</div> <!---form-group-->
<div class="form-group">
<label class="col-md-3 control-label" >Product Keywords</label>
<div class="col-md-6">
<input type="text" name="product_keywords" class="form-control" required>
</div>
</div> <!---form-group-->
<div class="form-group">
<label class="col-md-3 control-label" >Product Description</label>
<div class="col-md-6">
<textarea name="product_desc" class="form-control" rows="6" cols="19" style="max-width:100%; max-height:100%;"></textarea>
</div>
</div> <!---form-group-->
<div class="form-group">
<label class="col-md-3 control-label" ></label>
<div class="col-md-6">
<input type="submit" name="submit" value="Insert Product" class="btn btn-primary form-control">
</div>
</div> <!---form-group-->
</form> <!--form-horizontal ends--->
</div> <!--panel-body ends-->
</div> <!---panel panel-default ends-->
</div> <!--col-lg-12 ends--->
</div> <!--row 2 ends-->
</body>
</html>
<?php
if(isset($_POST['submit'])){
$product_title=$_POST['product_title'];
$product_cat=$_POST['product_cat'];
$cat=$_POST['cat'];
$product_price=$_POST['product_price'];
$product_desc=$_POST['product_desc'];
$product_keyword=$_POST['product_keywords'];
$product_img1=$_FILES['product_img1']['name'];
$product_img2=$_FILES['product_img2']['name'];
$product_img3=$_FILES['product_img3']['name'];
$temp_name1=$_FILES['product_img1']['tmp_name'];
$temp_name2=$_FILES['product_img2']['tmp_name'];
$temp_name3=$_FILES['product_img3']['tmp_name'];
move_uploaded_file($temp_name1,"product_images/$product_img1");
move_uploaded_file($temp_name2,"product_images/$product_img2");
move_uploaded_file($temp_name3,"product_images/$product_img3");
$insert_product="insert into products(p_cat_id,cat_id,date,product_title,product_img1,product_img2,product_img3,product_price,product_desc,product_keywords) values( '$product_cat','$cat',NOW(),'$product_title','$product_img1','$product_img2','$product_img3','$product_price','$product_desc','$product_keyword')";
$run_product=mysqli_query($conn,$insert_product);
if($run_product){
echo "<script>alert('Product has been inserted successfully')</script>";
echo "<script>window.open('insert.php','self')</script>";
}
}
?>
Even after defining variable i get error Undefined index: product_price in C:\xampp\htdocs\RangProject\admin_area\insert_products.php on line 183
this is my line 183
$product_price=$_POST['product_price'];
can someone tell me what my mistake is?? Php is quite confusing and case sensitive.
check if your post is not empty before assigning.
$product_price = isset($_POST['product_price']) ? $_POST['product_price'] : '';
fixed my error. Just added this after taking some advice from all my replies i got. Thanks everyone.
$product_title=mysqli_real_escape_string($conn,$_POST['product_title']);
$product_cat=mysqli_real_escape_string($conn,$_POST['product_cat']);
$cat=mysqli_real_escape_string($conn,$_POST['cat']);
$product_price =mysqli_real_escape_string($conn,$_POST['product_price']);
$product_desc=mysqli_real_escape_string($conn,$_POST['product_desc']);
$product_keyword=mysqli_real_escape_string($conn,$_POST['product_keywords']);
This happens because "product_price" does not exist on $_POST.
To avoid this error, check if it exists first using isset():
$product_price = isset($_POST['product_price']) ? $_POST['product_price'] : '';

Create form using smarty function

Yes! that's the exact doubt I have. I was given an assignment of
Create a form using smarty functions
(fields should be First Name, Last Name, Address, Email, Gender,
Qualifications, Phone number, etc.)
and I don't have any idea what they are talking about. So I want to ask that is there any function() which is used for making form elements or any other possibilities?I tried searching on google but didn't get any positive result.
PHP Code
<?php
include_once "../prepengine-header.php";
$lets = $_POST['user_lang'][1];
$var = $_POST['user_lang'][0];
$var .= $lets;
$formdata = "";
if (isset($data['submit'])) {
$formdata .= $data['user_firstname']."\n" ;
$formdata .= $data['user_lastname']."\n" ;
$formdata .= $data['user_address']."\n" ;
$formdata .= $data['user_qual']."\n" ;
$formdata .= $data['user_gender']."\n" ;
$formdata .= $var."\n" ;
$formdata .= $data['user_email']."\n" ;
$formdata .= $data['user_num']."\n" ;
$formdata .= $data['user_select']."\n" ;
}
$theme->assign('data',$data);
$theme->assign('formdata',$formdata);
echo($theme->fetch('smartart/screen5-a (1).tpl'));
?>
Smarty code
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<form class="form-horizontal" name="registration_form" id="registration_form" method="post" action="#">
<div class="form-group">
<label class="control-label col-lg-2" for="firstname">First Name: <sup style="color: #FF0000;">*</sup></label>
<div class="col-lg-10">
<input type="text" name="firstname" id="firstname" placeholder="Enter firstname" class="form-control" required="required" />
</div>
</div>
<div class="form-group row">
<label class="control-label col-lg-2" for="lastname">Last Name: <span style="color: #FF0000;">*</span></label>
<div class="col-lg-10">
<input type="text" name="lastname" id="lastname" placeholder="lastname" class="form-control" required="required" />
</div>
</div>
<div class="form-group row">
<label class="control-label col-lg-2" for="address">Address <span style="color: #FF0000;">*</span></label>
<div class="col-lg-10">
<textarea id="address" name="address" class="form-control" placeholder="Provide Address" required="required"></textarea>
</div>
</div>
<div class="form-group row">
<label class="control-label col-lg-2" for="gender">Gender <span style="color: #FF0000;">*</span></label>
<div class="col-lg-10">
<{html_radios name='gender' values=$cust_id output=$cust_gender selected=$custom_id separator='<br />'}>
</div>
</div>
<div class="form-group row">
<label class="control-label col-lg-2" for="user_lang">Languages</label>
<div class="col-lg-10">
<{html_checkboxes name='user_lang' values=$cust_ids output=$cust_names selected=$customer_id separator='<br/>'}>
</div>
</div>
<div class="form-group row">
<label class="control-label col-lg-2" for="user_country">Country</label>
<div class="col-lg-10">
<{html_options name='select' options=$myOptions class="form-control"}>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="submit" name="submit" id="submit_button" class="btn btn-default" value="Submit">
</div>
</div>
</form>
</div>
</body>
</html>

PHP submit to self FAILING

** SOLVED: submit to self now working.**
My simple html/php (bootstrap) form refuses to submit to self. Can you see anything wrong with my code? I've tried the obvious $_SERVER['PHP_SELF'] and a number of other failures. Out of ideas.
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<div class="row">
<div class="col-lg-12">
<h2>Contact us!</h2>
<!-- changed this
<form name="enquiryform" method="post" action="">
<form class="form-horizontal">
-->
<!-- to this: --> <form class="form-horizontal" name="enquiryform" method="post" action="">
<div class="form-group-lg">
<label class="control-label col-xs-4" for="first_name">Name *</label>
<div class="col-xs-8">
<input type="text" class="form-control" id="name" placeholder="First name" name="first_name" required>
</div>
</div>
<div class="form-group-lg">
<label class="control-label col-xs-4" for="last_name">Surname</label>
<div class="col-xs-8">
<input type="text" class="form-control" id="surname" placeholder="Last name" name="last_name">
</div>
</div>
<div class="form-group-lg">
<label class="control-label col-xs-4" for="inputEmail">Email *</label>
<div class="col-xs-8">
<input type="email" class="form-control" id="inputEmail" placeholder="you#example.com" name="email" required>
</div>
</div>
<div class="form-group-lg">
<label class="control-label col-xs-4" for="telephone">Mobile</label>
<div class="col-xs-8">
<input type="tel" class="form-control" id="Mobile" placeholder="Phone number" name="telephone">
</div>
</div>
<div class="form-group-lg">
<label class="control-label col-xs-4" for="exampleTextarea" name="comments"></label>
<textarea class="form-control" id="exampleTextarea" rows="6" name="comments" placeholder="What is your enquiry?" required></textarea>
<div class="form-group">
<div class="col-xs-12">
<input type="submit" class="btn btn-primary" value="Submit">
</div>
</div>
</form>
</div>
</div>
</div>
<p></p>
<?php
//if "email" variable is filled out, send email
if (isset($_REQUEST['email'])) {
//Email information
$admin_email = "########gmail.com";
$first_name = $_REQUEST['first_name'];
$last_name = $_REQUEST['last_name'];
$email = $_REQUEST['email'];
$telephone = $_REQUEST['telephone'];
$comments = $_REQUEST['comments'];
//send email
mail($admin_email, "$first_name", $last_name, "$telephone", "$comments", "From:" . $email);
//Email response
echo "Thank you for contacting us!";
}
//if "email" variable is not filled out, display the form
else {
?>
<?php
}
?>
</body>
</html>
Change this
<form name="enquiryform" method="post" action="">
<h2>Contact us!</h2>
<form class="form-horizontal">
to
<form class="form-horizontal" name="enquiryform" method="post" action="#">
<h2>Contact us!</h2>

Categories