I've made a simple project in which a user can register his account, login with his credentials, view his blog posts and create a new blog. I'm currently working on creating a new blog which is simple a form with two options: blog title and content. I'm stuck with the part where you hit submit and the form is passed to the controller specified in form_open function. Nothing is happening when I hit the submit button, this is the issue.
Here is my view file:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<meta charset="utf-8">
<title>Enter your Title</title>
</head>
<body>
<div class="container">
<div class="jumbotron">
<?=form_open("blog/submitpost"); ?>
<div class="form-horizontal">
<div class="form-group">
<label for="blogtitle" class="control-label col-sm-2">Blog Title</label>
<div class="col-sm-8">
<input type="text" name="blogtitle" placeholder="Enter your title here" class="form-control">
</div>
</div>
<div class="form-group">
<label for="blogdesc" class="control-label col-sm-2">Blog Title</label>
<div class="col-sm-8">
<textarea name="blogdesc" rows="8" cols="40" class="form-control" placeholder="Enter your post here"></textarea>
</div>
</div>
</div>
<?=form_close();?>
<div style="text-align: center;">
<button type="submit" name="submit" class="btn btn-success">Submit</button>
</div>
</div>
</div>
</body>
</html>
And here is my controller
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Blog extends CI_Controller{
function __construct(){
parent::__construct();
$this->load->model('user');
$this->load->helper('form');
}
public function new_post($id){
$data['id'] = $id;
$this->load->view('blog_new_post',$data);
}
public function blogpostview($id){
$session_data = $this->session->userdata('logged_in');
$data['username'] = $session_data['username'];
$data['id'] = $id;
$data['posts'] = $this->user->blog_post_list($data['username']);
$this->load->view('blog_view',$data);
}
public function submitpost(){
//there will be additional code here
$this->load->view('blog_post_view');
}
}
?>
Now firstly, I'm aware one has to load the Form helper class to achieve this, which I've already done. I've even changed the autoload.php file to automatically load it.
Secondly, I've already implemented this twice during registration and login processes. This time however I don't know why the code isn't working.
Okay I got the solution and it's a very simple one. I had not placed the submit button in the form due to which the problem was coming! Sometimes it's the simplest solutions that work out.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<meta charset="utf-8">
<title>Enter your Title</title>
</head>
<body>
<div class="container">
<div class="jumbotron">
<?php echo form_open("blog/submitpost"); ?>
<div class="form-horizontal">
<div class="form-group">
<label for="blogtitle" class="control-label col-sm-2">Blog Title</label>
<div class="col-sm-8">
<input type="text" name="blogtitle" placeholder="Enter your title here" class="form-control">
</div>
</div>
<div class="form-group">
<label for="blogdesc" class="control-label col-sm-2">Blog Title</label>
<div class="col-sm-8">
<textarea name="blogdesc" rows="8" cols="40" class="form-control" placeholder="Enter your post here"></textarea>
</div>
</div>
</div>
<div style="text-align: center;">
<button type="submit" name="submit" class="btn btn-success">Submit</button>
</div>
<?=form_close();?>
</div>
</div>
</body>
</html>
try this
<?php
$attributes = array('name' => 'add_blog','id' => 'add_blog', 'method' =>'POST')
echo form_open("blog/submitpost", $attributes); ?> //form open
<?php echo form_close(); ?> //form close
Try this.....
<?php
$data = array('action' =>'blog/submitpost','id' => 'add_blog', 'method' =>'POST', )
echo form_open("blog/submitpost", $data); ?>
<div class="form-horizontal">
<div class="form-group">
<label for="blogtitle" class="control-label col-sm-2">Blog Title</label>
<div class="col-sm-8">
<input type="text" name="blogtitle" placeholder="Enter your title here" class="form-control">
</div>
</div>
<div class="form-group">
<label for="blogdesc" class="control-label col-sm-2">Blog Title</label>
<div class="col-sm-8">
<textarea name="blogdesc" rows="8" cols="40" class="form-control" placeholder="Enter your post here"></textarea>
</div>
</div>
</div>
<div style="text-align: center;">
<button type="submit" name="submit" class="btn btn-success">Submit</button>
</div>
<?php echo form_close(); ?>
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I have a booking form and I successfully connected my database to my website. When I go to my database in MYSQL to see the data I inserted, all fields are in zeros. I tried changing my type of my data fields in the database but it didn't work.
My website connection with the MYSQL database:
<?php
$conexao=mysqli_connect("localhost", "root", "", "sitepap2");
?>
Code to sends the data inserted in the form to the database and to check if there's already a similar record in the database:
<?php
include("conecta.php");
$pnome=$_POST['pnome'];
$numerotmv=$_POST['numerotmv'];
$localsessao=$_POST['localsessao'];
$data=$_POST['data'];
$hora=$_POST['hora'];
$pesquisaUsuario = mysqli_num_rows(mysqli_query($conexao,"
SELECT nome FROM agendamento
WHERE numerotmv = '$numerotmv'
"));
if($pesquisaUsuario >0){
echo 1;
}else{
mysqli_query($conexao, "
insert into agendamento
(pnome, numerotmv, localsessao, data, hora)
values
('$pnome','$numerotmv', '$localsessao','$data','$hora')
");
echo 0;
}
?>
My index file where the form is displayed:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>PHP form</title>
</head>
<body>
<div class="modal fade" id="calendario" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-body">
<!-- Registro -->
<form name="calendario" id="calendario" method="post" class="form-horizontal">
<div>
<button type="button" class="close" data-dismiss="modal">×</button>
<h2 class="text-uppercase align-self-end text-center">Agendamento</h2>
<hr class="divider">
</div>
<div class="form-group">
<label class="control-label col-xs-4">Primeiro Nome</label>
<div class="col-xs-8">
<input type="text" class="form-control" name="pnome" required="required">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-4">Número de telemóvel</label>
<div class="col-xs-8">
<input type="text" class="form-control" name="numerotmv" required="required">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-4">Local da Sessão</label>
<div class="col-xs-8">
<input type="text" class="form-control" name="localsessao" required="required">
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<input class="form-control" name="data" type="date" required>
<span class="form-label">Data</span>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<input class="form-control" name="hora" type="time" required>
<span class="form-label">Hora</span>
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-8 col-xs-offset-4">
<button type="submit" onClick="verificarAgendamento()" class="btn btn-primary btn-lg">Agendar</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
function verificarAgendamento(){
event.preventDefault();
$.ajax({
type: "POST",
url: "agendamento.php",
data: $("#calendario").serialize(),
success: function(resultado){
if(resultado==0){
alert("Booking made with success");
}else{
alert("error");
}
return false;
}
});
$('#calendario')[0].reset();
return false;
}
</script>
</body>
</html>
My database structure:
database
What happens when I try to insert data through my PHP form in the database:
problem
Thank to all the people that spent time reading this post to help me. I'm grateful.
You have two id's called calendario. The form and the div. So your ajax request is serializing the div, not the form.
Change one of the ids to a unique value and it will work e.g.:
NOTE: If you change the id of your form you need to change it in your ajax call as well
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>PHP form</title>
</head>
<body>
<div class="modal fade" id="calendario" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-body">
<!-- Registro -->
<form name="calendario" id="calendario-form" method="post" class="form-horizontal">
<div>
<button type="button" class="close" data-dismiss="modal">×</button>
<h2 class="text-uppercase align-self-end text-center">Agendamento</h2>
<hr class="divider">
</div>
<div class="form-group">
<label class="control-label col-xs-4">Primeiro Nome</label>
<div class="col-xs-8">
<input type="text" class="form-control" name="pnome" required="required">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-4">Número de telemóvel</label>
<div class="col-xs-8">
<input type="text" class="form-control" name="numerotmv" required="required">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-4">Local da Sessão</label>
<div class="col-xs-8">
<input type="text" class="form-control" name="localsessao" required="required">
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<input class="form-control" name="data" type="date" required>
<span class="form-label">Data</span>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<input class="form-control" name="hora" type="time" required>
<span class="form-label">Hora</span>
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-8 col-xs-offset-4">
<button type="submit" onClick="verificarAgendamento()" class="btn btn-primary btn-lg">Agendar</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
function verificarAgendamento(){
event.preventDefault();
$.ajax({
type: "POST",
url: "agendamento.php",
data: $("#calendario-form").serialize(),
success: function(resultado){
if(resultado==0){
alert("Booking made with success");
}else{
alert("error");
}
return false;
}
});
$('#calendario')[0].reset();
return false;
}
</script>
</body>
</html>
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>
How do I save my user input to a simple .txt?
I am really new to php so please help me out here.
My code:
<?php
if(isset($_POST['email']) && isset($_POST['password'])) {
$data = $_POST['email'] . '-' . $_POST['password'] . "\n";
$ret = file_put_contents('/tmp/mydata.txt', $data, FILE_APPEND | LOCK_EX);
if($ret === false) {
die('There was an error writing this file');
}
else {
echo "$ret bytes written to file";
}
}
else {
die('no post data to process');
}
?>
Don't think I need to include this but I found a really cool looking login form and changed the names of course:
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>Material Login Form</title>
<link rel="stylesheet" href="css/reset.css">
<link rel='stylesheet prefetch' href='http://fonts.googleapis.com/css?family=Roboto:400,100,300,500,700,900|RobotoDraft:400,100,300,500,700,900'>
<link rel='stylesheet prefetch' href='http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css'>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<!-- Mixins-->
<!-- Pen Title-->
<div class="pen-title">
<h1>Material Login Form</h1></div>
<div class="rerun">Rerun Pen</div>
<div class="container">
<div class="card"></div>
<div class="card">
<h1 class="title">Login</h1>
<form>
<div class="input-container">
<input name="email" type="text" id="Username" required="required"/>
<label for="Username">Email</label>
<div class="bar"></div>
</div>
<div class="input-container">
<input name="password" type="password" id="Password" required="required"/>
<label for="Password">Password</label>
<div class="bar"></div>
</div>
<div class="button-container">
<button><span>Go</span></button>
</div>
<div class="footer">Forgot your password?</div>
</form>
</div>
<div class="card alt">
<div class="toggle"></div>
<h1 class="title">Register
<div class="close"></div>
</h1>
<form>
<div class="input-container">
<input type="text" id="Username" required="required"/>
<label for="Username">Email</label>
<div class="bar"></div>
</div>
<div class="input-container">
<input type="password" id="Password" required="required"/>
<label for="Password">Password</label>
<div class="bar"></div>
</div>
<div class="input-container">
<input type="password" id="Repeat Password" required="required"/>
<label for="Repeat Password">Repeat Password</label>
<div class="bar"></div>
</div>
<div class="button-container">
<button><span>Next</span></button>
</div>
</form>
</div>
</div>
<!-- Portfolio--><a id="portfolio" href="http://andytran.me/" title="View my portfolio!"><i class="fa fa-link"></i></a>
<!-- CodePen--><a id="codepen" href="http://codepen.io/andytran/" title="Follow me!"><i class="fa fa-codepen"></i></a>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src="js/index.js"></script>
</body>
</html>
I'm at a loss here, I have no clue what to fix!
something like this:
$content = $_POST['email'];
$myfile = fopen("".$name.".txt", "w") or die("error"); // make txt file
fwrite($myfile, $content); // write some content
fclose($myfile); // save and close
<div class="pen-title">
<h1>Material Login Form</h1></div>
<div class="rerun">Rerun Pen</div>
<div class="container">
<div class="card"></div>
<div class="card">
<h1 class="title">Login</h1>
<form action="upload.php" method="post">
<div class="input-container">
<input name="email" type="text" id="Username"
required="required"/>
<label for="Username">Email</label>
<div class="bar"></div>
</div>
<div class="input-container">
<input name="password" type="password"
id="Password" required="required"/>
<label for="Password">Password</label>
<div class="bar"></div>
</div>
<div class="button-container">
<button type="submit">Go</button>
</div>
<div class="footer"><a href="#">Forgot your password?
</a></div>
</form>
</div>
</div>
//in php file use this code for saving file
$myfile= fopen('/tmp/mydata.txt','w') or die("Unable to open file!");;
fwrite($myfile,$_POST);//or $data
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.
This form Submission is not working, Can anyone help me...
I am using bootstrap css and trying to submit a simple form, there is a small issue but I can't detect the problem, please help
<div class="container">
<div class="thumbs askus container col-md-6 col-md-offset-4">
<form id="logfrm" action="" method="post" class="form-horizontal">
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Username</label>
<div class="col-sm-4">
<input type="text" name="unm" class="form-control" id="inputUser" placeholder="Username">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">Password</label>
<div class="col-sm-4">
<input type="password" name="pwd" class="form-control" id="inputPassword" placeholder="Password">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-4">
<div class="checkbox">
<label>
<input type="checkbox"> Remember me
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-4">
<button class="btn btn-default" >Sign in</button>
</div>
</div>
</form>
</div>
</div>
PHP Code for form handling
if (isset($_POST['unm'])) {
if ($_POST['unm']=="admin" && $_POST['pwd']=="xxxxxx") {
echo '<script type="text/javascript">alert("Hi Admin");</script>';
header('Location: home.php');
}
else{
echo '<script type="text/javascript">alert("Unknown Username/Bad password");</script>';
}
}
If your php for this form is on the same page, then it would make sense to direct the action to the same page. That way, the form will be sent to a refreshed version of the page where the PHP will pick it up and process it from there.
so - if you form is on a page called form.php
then it should be
<form id="logfrm" action="form.php" method="post" class="form-horizontal">
You can monitor the $_POST['umn'] using Firebug to see that everything is send properly
You just missed the action url so that the form submission does not working ... I just change the form action tag from action="" to action="action.php" where action.php is the file containing your php codes to handle the html form.Use the below Code this will solve your problem.
home.php
<?php
if(isset($_POST['submit_button']))
{
if ($_POST['unm']=="admin" && $_POST['pwd']=="xxxxxx") {
echo '<script type="text/javascript">alert("Ok");</script>';
header('Location:home.php');
}
else{
echo '<script type="text/javascript">alert("Unknown Username/Bad password"); if(confirm("Unknown Username/Bad password")){document.location.reload(true);}</script>';
}
}
else
{
?>
<!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>Bootstrap 101 Template</title>
<!-- Bootstrap -->
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
</head>
<body><br/><br/><br/><br/>
<div class="container">
<div class="thumbs askus container col-md-6 col-md-offset-4">
<form id="logfrm" method="post" class="form-horizontal" action="home.php">
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Username</label>
<div class="col-sm-4">
<input type="text" name="unm" class="form-control" id="inputUser" placeholder="Username">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">Password</label>
<div class="col-sm-4">
<input type="password" name="pwd" class="form-control" id="inputPassword" placeholder="Password">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-4">
<div class="checkbox">
<label>
<input type="checkbox"> Remember me
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-4">
<button type="submit" class="btn btn-default" name="submit_button" >Sign in</button>
</div>
</div>
</form>
</div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
</body>
<?php } ?>
</html>