I have a html form with one text field and one bootstrap module popup and two types of submit.
I'am able to collect the value from the html field using $_POST but I'am not getting the value from the popup window.
HTML :
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<form id="contactform" method="post" action="http://****/post.php">
<tr>
<td>
<label for="name">Name :</label>
</td>
<td>
<input type="text" name="name">
</td>
</tr>
<tr>
<td>
<button type="submit"> Submit</button>
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Update</button>
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<label for="plan">Plan :</label>
<input type="radio" name="plan" value="Yes" > Yes</input>
<input type="radio" name="plan" value="No"> No</input>
</div>
<div class="modal-footer">
<button type="submit" formaction="update.php" class="btn btn-default" data-dismiss="modal">Submit</button>
</div>
</div>
</div>
</div>
</td>
</tr>
</form>
</body>
</html>
Here for two submits am using two php files: post.php and update.php
Where one submit is outside (post.php) the popup and other inside (update.php) the popup.
In post.php I am only collecting text field using
$name = $_POST['name'];
Which is working, but not in update.php code:
<?php
$conn = mysqli_connect("localhost", "username", "password", "database");
if($conn === false){
die("ERROR: Could not connect. " . mysqli_connect_error($conn));
}
$name = $_POST['name'];
$plan = $_POST['plan'];
$sql = "INSERT INTO table (name, plan) VALUES ('$name', '$plan')";
if(mysqli_query($conn, $sql)){
echo "Records added successfully.";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($conn);
}
?>
Here in db I'am only able to collect name.
Please help to collect the values form both html field (name) and popup window field (plan).
Thanks in advance.
For your button in popup remove data-dismiss like this:
<button type="submit" formaction="update.php" class="btn btn-default">Submit</button>
Then in your post.php process just $name and in update.php $plan and $post.
Related
I don't know what I've done but I think I have some error in my ajax query. I am expecting to have been able to see the missing details not entered in the signup form. I get 500 server error and undefined $("#signupform") errors.
I have tried searching here and tried inserting various comments into my code to try and see if it helps. I have only been coding for 10 weeks so it's all new to me. I took an online course that promised the earth but has zero support whatsoever.
I think the error may be coming from the connection.php file I have not allowing the code to progress to check out my input fields in the table?
I have these pages hosted on a subdomain here is the link http://welcomer.offyoucode.co.uk/WEBSITES/9.Notes%20App/ in case its easier to figure it out from there.
<!--connect to the database-->
<?php
$link = mysqli_connect("#", "#", "#", "#");
if(mysqli_connect_error()){
die("ERROR: Unable to connect:" . mysqli_connect_error());
echo "<script>window.alert('Hi!')</script>";
}
?>
<!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>Online Notes</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link href="styling.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Arvo&display=swap" rel="stylesheet">
<style>
</style>
</head>
<body>
<!--navbar-->
<nav role="navigation" class="navbar navbar-custom navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand">Online Notes</a>
<button type="button" class="navbar-toggle" data-target="#navbarCollapse" data-toggle="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 class="navbar-collapse collapse" id="navbarCollapse">
<ul class="nav navbar-nav">
<li class="active">Home<span class="caret"></span></li>
<li>Help</li>
<!--<li>Sign-Up</li>-->
<li>Contact Us</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Login</li>
</ul>
</div>
</div>
</nav>
<!--jumbotron with signup button-->
<div class="jumbotron" id="myContainer">
<h1>Online Notes App</h1>
<p>Your notes with you, wherever you go.</p>
<p>Easy to use, protects all your notes!</p>
<button type="button" class="btn btn-lg green signup" data-target="#signupModal" data-toggle="modal">Sign up - Its free</button>
</div>
<!--login form-->
<form method="post" id="loginform">
<div class="modal" id="loginModal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button class="close" data-dismiss="modal">×</button>
<h4 id="myModalLabel">Login:</h4>
</div>
<div class="modal-body">
<!--login message from php file-->
<div id="loginmessage"></div>
<div class="form-group">
<label for="loginemail" class="sr-only">Email:</label>
<input class="form-control" type="email" name="loginemail" id="loginemail" placeholder="Email" maxlength="50">
</div>
<div class="form-group">
<label for="loginpassword" class="sr-only">Password</label>
<input class="form-control" type="password" name="loginpassword" id="loginpassword" placeholder="Password" maxlength="40">
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="rememberme" id="rememberme">
Remember me
</label>
<a class="pull-right" style="cursor: pointer" data-dismiss="modal" data-target="#forgotpasswordModal" data-toggle="modal">
Forgot Password?
</a>
</div>
</div>
<div class="modal-footer">
<input class="btn green" name="login" type="submit" value="Login">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" data-target="signupModal" data-toggle="modal">Register</button>
</div>
</div>
</div>
</div>
</form>
<!--signup form-->
<form method="post" id="signupform">
<div class="modal" id="signupModal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button class="close" data-dismiss="modal">×</button>
<h4 id="myModalLabel">Sign up today and start using our Online Notes App! </h4>
</div>
<!--signup message from php file-->
<div id="signupmessage"></div>
<div class="modal-body">
<div class="form-group">
<label for="username" class="sr-only">Username:</label>
<input class="form-control" type="text" name="username" id="username" placeholder="Username" maxlength="35">
</div>
<div class="form-group">
<label for="email" class="sr-only">Email:</label>
<input class="form-control" type="email" name="email" id="email" placeholder="Email" maxlength="50">
</div>
<div class="form-group">
<label for="password" class="sr-only">Password:</label>
<input class="form-control" type="password" name="password" id="password" placeholder="Choose a password" maxlength="40">
</div>
<div class="form-group">
<label for="password2" class="sr-only">ConfirmPassword:</label>
<input class="form-control" type="password" name="password2" id="password2" placeholder="Confirm password" maxlength="40">
</div>
</div>
<div class="modal-footer">
<input class="btn green" name="signup" type="submit" value="Sign up">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
</form>
<!--forgot password form-->
<form method="post" id="forgotpasswordForm">
<div class="modal" id="forgotpasswordModal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button class="close" data-dismiss="modal">×</button>
<h4 id="myModalLabel">Forgot Password? Enter your Email address:</h4>
</div>
<div class="modal-body">
<!--forgot password message from php file-->
<div id="forgotpasswordMessage"></div>
<div class="form-group">
<label for="forgotpasswordEmail" class="sr-only">Email:</label>
<input class="form-control" type="email" name="forgotpasswordEmail" id="forgotpasswordEmail" placeholder="Email" maxlength="50">
</div>
</div>
<div class="modal-footer">
<input class="btn green" name="login" type="submit" value="Login">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" data-target="signupModal" data-toggle="modal">Register</button>
</div>
</div>
</div>
</div>
</form>
<?php
include "footer.php";
?>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="index.js"></script>
</body>
</html>
//Ajax Call for the sign up form
//once the form is submitted
$("#signupform").submit(function(event){
//prevent default php processing
event.preventDefault();
//collect user inputs
var datatopost =
$(this).serializeArray();
console.log(datatopost);
//send them to signup.php using ajax
$.ajax({
url: "signup.php",
type: "POST",
data: datatopost,
success: function(data){
if(data){
$("#signupmessage").html(data);
}
},
error: function(){
$("#signupmessage").html("<div class='alert alert-danger'>There was an error with the Ajax Call. Please try again later.</div>");
},
});
// $.post({}).done().fail();
});
//ajax call successful: show error or success message
//ajax call fails: show ajax call error
//ajax call for the login form
//once the form is submitted
//prevent default php processing
//collect user inputs
//send them to login.php using ajax
//if php files return "success": redirect user to notes page
//otherwise show error message
//ajax call fails: show ajax call error
//ajax call for the forgot password form
//once the form is submitted
//prevent default php processing
//collect user inputs
//send them to login.php using ajax
//ajax call successful: show error or success message
//ajax call fails: show ajax call error
<?php
//<!--start session-->
session_start();
include("connection.php");
//<!--check user inputs-->
// <!--define error messages-->
$missingUsername='<p><strong>Please enter a username</strong></p>';
$missingEmail='<p><strong>Please enter an email address</strong></p>';
$invalidEmail='<p><strong>Please enter a valid email address</strong></p>';
$missingPassword='<p><strong>Please enter a password</strong></p>';
$invalidPassword='<p><strong>Your password should be at least 8 characters long and contain at least 1 capital letter and 1 number!</strong></p>';
$differentPassword='<p><strong>Passwords do not match! </strong></p>';
$missingPassword2='<p><strong>Please confirm your password</strong></p>';
$errors = "";
$username = "";
$email = "";
$password = "";
$myFile = "db.json";
$arr_data = array(); //create empty array
// <!--get username, email, password, password2-->
//get username
if(empty($_POST["username"])){
$errors .= $missingUsername;
}else{
$username = filter_var($_POST["username"], FILTER_SANITIZE_STRING);
}
//get email
if(empty($_POST(["email"]))){
$errors .= $missingEmail;
}else{
$email = filter_var($_POST["email"],
FILTER_SANITIZE_EMAIL);
if(!filter_var($email, FILTER_VALIDATE_EMAIL)){
$errors .= $invalidEmail;
}
}
// get passwords
if(empty($_POST["password"])){
$errors .= $missingPassword;
}elseif(!(strlen($_POST["password"])>= 8 and preg_match('/[A-Z]/', $_POST["password"])and
preg_match('/[0-9]/', $_POST["password"])
)
){
$errors .= $invalidPassword;
}else{
$password = filter_var($_POST["password"], FILTER_SANITIZE_STRING);
if(empty($_POST["password2"])){
$errors .= $missingPassword2;
}else{
$password2 = filter_var($_POST["password2"], FILTER_SANITIZE_STRING);
if($password !== $password2){
$errors .= $differentPassword;
}
}
}
// <!--if there are any errors print errors-->
if($errors){
$resultMessage = '' . $errors . '';
echo $resultMessage;
exit;
}
//<!--no errors-->
// <!--prepare variables for the query-->
$username = mysqli_real_escape_string($link, $username);
$email = mysqli_real_escape_string($link, $email);
$password = mysqli_real_escape_string($link, $password);
$password = md5($password);
//128 bits -> 32 characters
// <!--if username exists in the table print error-->
$sql = "SELECT * FROM users WHERE username = '$username'";
mysqli_query($link, $sql);
if($!result){
echo '<div class="alert alert-danger">Error running the query!</div>';
// echo '<div class="alert alert-danger">' . mysqli_error($link) . '</div>';
exit;
}
$results = mysqli_num_rows($results);
if($results){
echo '<div class="alert alert-danger">That username is already in use. Do you want to log in?</div>'; exit;
}
// <!--else-->
// <!--if email exists in the users table print error-->
$sql = "SELECT * FROM users WHERE email = '$email'";
mysqli_query($link, $sql);
if(!$result){
echo '<div class="alert alert-danger">Error running the query!</div>';
exit;
}
$results = mysqli_num_rows($results);
if($results){
echo '<div class="alert alert-danger">That email is already in use. Do you want to log in?</div>'; exit;
}
// <!--else-->
// <!--create a unique activation code-->
$activationKey = bin2hex(openssl_random_pseudo_bytes(16));
//byte: unit of data = 8 bits
//bit: 0 or 1
//16 bytes = 16*8 = 128 bits
//2*2*2*2*2*2....*2
//16*16.......*16
//32 characters
// <!--insert user details and activation code in the users table-->
$sql = "INSERT INTO users ('username', 'email', 'password', 'activation') VALUES ('$username', '$email', '$password', '$activationKey')";
mysqli_query($link, $sql);
if(!$result){
echo '<div class="alert alert-danger">There was an error inserting the user details into the database</div>';exit;
}
// <!--send the user an email with a link to activate.php with their email and activation code-->
$message = "Please click on this link to activate your account:\n\n";
$message = "http://https://welcomer.offyoucode.co.uk/WEBSITES/9.Notes%20App/activate.php?email=" . urlencode($email) . "&key=$activationKey"; if(mail($email, 'Confirm your Registration', $message, 'From:'.'onlinenotes#gmail.com')){
echo '<div class="alert alert-success">Thank you for registering. A confirmation email address has been sent to $email. Please click on the activation link to activate your account.</div>';
}
?>
Solved! On line 34 in signup.php extra brackets around email input. Solved using ERROR_REPORTING(E_ALL); ini_set('display_errors', 1) to narrow down my fault.
I have a sample code below which consists of a simple bootstrap modal for delete confirmation message. The code is working perfectly,while i give input type= button , but once i give type=submit it does not submit form and dialog modal dont open. Here is my code.
<?php
if(isset($_POST['submit'])){
echo $_POST['first_name'];
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<script type="text/javasript">
$('.submit').click(function(e){
e.preventDefault();
});
</script>
<title>JS Bin</title>
</head>
<body>
<form action="" method="post">
<input type="text" name="first_name" id="first_name">
<!--<button type="button" class="btn btn-default" data-toggle="modal" data-target="#confirm-submit">Submit</button>-->
<button type="submit" name="submit" class="btn btn-default" data-toggle="modal" data-target="#confirm-submit">Submit</button>
<div class="modal fade" id="confirm-submit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h2 class="modal-title">Confirm</h2>
</div>
<div class="modal-body">
<p>Are you sure you want to submit?</p>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-success">Yes, Submit</button>
<button type="submit" name="" class="btn btn-danger" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
</form>
</body>
</html>
Please help me..
In the modal footer [SOLVED]
<div class="modal-footer">
<button type="submit" class="btn btn-success">Yes, Submit</button>
<button type="submit" name="submit" class="btn btn-danger" data-dismiss="modal">Cancel</button>
</div>
As your first button on the form,
<button type="submit" name="submit" class="btn btn-default" data-toggle="modal" data-target="#confirm-submit">Submit</button>
opens the modal but doesn't submit the form as you have used e.preventDefault(); on that button click,
After modal opens once you click on 'Yes, Submit' it will submit the form again but this time isset($_POST['submit']) will be blank as the 'Yes, Submit' button doesn't have name.
Just add name to that button and it will work.
Final code will look like as above [SOLVED]
<script type="text/javascript">
$(document).on('submit', 'form', function(e){
e.preventDefault();
});
</script>
You (first) have a typo in the script tag (should be javascript).
Then you have to listen to the submit of the form to prevent it. You listen to a click of an element with the class submit which doesn't exist.
I have a login page here in which there are two fields and a submit button. The code looks fine but when I press the submit button nothing is passed to the isset method. Here are my codes.
<?php
function security($database,$value)
{
$new_val=stripslashes($value);
$new_val=mysqli_real_escape_string($database,$value);
return $new_val;
}
require_once("database.php");
if(isset($_POST['submit']))
{
echo "working";
$username=security("betit",$_POST['username']);
$paassword=security("betit",$_POST['password']);
$sql="SELECT * FROM user_info WHERE username='$username' and password='$password'";
$result=mysqli_query("betit",$sql);
if($result)
{
echo "congrats";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>LOGIN</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.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<h3>Login</h3>
<div class="col-3">
<form method="post" action="" >
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input id="email" type="text" class="form-control" name="username" placeholder="Username">
</div>
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
<input id="password" type="password" class="form-control" name="password" placeholder="Password">
</div>
<input type="button" class="btn btn-primary" name="submit" value="submit">
</form>
</div>
</div>
</div>
</body>
</html>
The database.php
<?php
function db_connection($hostname, $username, $password, $database)
{
$link = mysqli_connect($hostname, $username, $password, $database);
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
echo "Connect Successfullyworking. Host info: " . mysqli_get_host_info($link);
}
db_connection("localhost", "root", "", "betit")
?>
Submit button was supposed to invoke the isset method but nothing is passing.I just cant identify what kind of error is it.
You have given type as button on submit input. change it to type="submit"
I think the problem is in Button
Change
<input type="button" class="btn btn-primary" name="submit" value="submit">
To
<input type="submit" class="btn btn-primary" name="submit" value="submit">
I have a search bar for users to enter a query. Upon clicking 'Search', a modal should appear with the query results.
My output from index.php is still not showing in the modal. When I click 'Search', the modal pops up with an empty body. How do I get my output from index.php to show in the modal's body?
index.php
<head>
<title>Search</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>
<form method="POST" action="#">
<input type="text" name="q" placeholder="Enter query"/>
<input type="button" name="search" value="Search" data-toggle="modal" data-target="#mymodal">
</form>
</body>
<script>
$('form').submit(function(e){
e.preventDefault() // do not submit form
// do get request
$.get( 'search.php', { q : },function(e){
// then show the modal first
$('#mymodal').modal('show');
// then put the results there
$('#mymodal:visible .modal-container .modal-body').html(e);
});
});
</script>
<!-- The Modal -->
<div class="modal" id="mymodal">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Modal Heading</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
search.php
<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
include_once('db.php'); //Connect to database
if(isset($_POST['q'])){
$q = $_POST['q'];
//get required columns
$query = mysqli_query($conn, "SELECT * FROM `words` WHERE `englishWord` LIKE '%$q%' OR `yupikWord` LIKE '%$q%'") or die(mysqli_error($conn)); //check for query error
$count = mysqli_num_rows($query);
if($count == 0){
$output = '<h2>No result found</h2>';
}else{
while($row = mysqli_fetch_assoc($query)){
$output .= '<h2>'.$row['yupikWord'].'</h2><br>';
$output .= '<h2>'.$row['englishWord'].'</h2><br>';
$output .= '<h2>'.$row['audio'].'</h2><br>';
$audio_name = $row['audio'];
$output .= '<td><audio src="audio/'.$audio_name.'" controls="control">'.$audio_name.'</audio></td>';
}
}
echo $output;
}else{
"Please add search parameter";
}
mysqli_close($conn);
?>
I know this question has many solutions in SO.But still I cant spot my mistake.The following is my bootstrap modal form
<!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="assets/lib/bootstrap/css/bootstrap.min.css">
<script src="../asset/modal/js/jquery.min.js"></script>
<script src="assets/lib/bootstrap/js/bootstrap.min.js"></script>
</head>
<body>
<? if(isset($_POST["sendmail"]))
echo "Form 1 have been submitted";
?>
<div class="container">
<!-- Trigger the modal with a button -->
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<? echo $token; ?>
<!-- Modal content-->
<form class="form-horizontal" role="form" method="post" name="sendmail" >
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<textarea rows="8" class="form-control"></textarea>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-default" >Send</button>
</div>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
But whenever i submit the form it redirects to the index page of my project.Please Help me spotting my error.:-(
Yes its because you are not directing it anywhere...You need to write something like this:-
<form class="form-horizontal" role="form" method="post" name="sendmail" action="page_name_here.php" >
So you need to add action="page_name_here.php">
If you want to stay on the same page then just write action="#">
Update:-
<button type="submit" class="btn btn-default" name="send">Send</button>
Add a name to the button send then in the Php:-
<? if(isset($_POST["send"]))
echo "Form 1 have been submitted";
?>
This way when you click the send button everything in the form is submitted, since its a button of type=submit
Use this for the submit button. Your button has not been named as sendmail for the POST so the info will not pass.
<? if(isset($_SERVER['REQUEST_METHOD'] == 'POST' ))
echo "Form 1 have been submitted";
?>
Add empty action as shown for the same page
<form class="form-horizontal" role="form" method="post" name="sendmail" action="">