PHP Error about session start - php

i am getting this error when i uploaded my website "Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /storage/ssd3/749/6048749/public_html/index.php:1" it works fine in localhost but not in remote server. this is my code:
<?php
$host="localhost";
$uname="id6048749_cman";
$pas="";
$db_name="id6048749_cman";
$tbl_name="admin";
$con = #mysqli_connect("$host","$uname","$pas") or die ("cannot connect");
mysqli_select_db($con , "$db_name") or die ("cannot select db");
?>
<form id="login_form1" class="form-signin" method="post">
<h3 class="form-signin-heading">
<i class="icon-lock"></i> Administrator Login
</h3>
<input type="text" class="input-block-level" id="username" name="username" placeholder="Username" required>
<input type="password" class="input-block-level" id="password" name="password" placeholder="Password" required>
<button data-placement="right" title="Click Here to Sign In" id="signin" name="login" class="btn btn-info" type="submit"><i class="icon-signin icon-large"></i> Sign in</button>
<script type="text/javascript">
$(document).ready(function(){
$('#signin').tooltip('show');
$('#signin').tooltip('hide');
});
</script>
</form>
</br>
<div class="error">
<?php
if (isset($_POST['login'])){
$username=$_POST['username'];
$password=$_POST['password'];
$login_query=mysqli_query($con , "select * from admin where username='$username' and password='$password'");
$count=mysqli_num_rows($login_query);
$row=mysqli_fetch_array($login_query);
if ($count > 0){
session_start();
$_SESSION['id']=$row['admin_id'];
header('location:dashboard.php');
}else{
header('location:index.php');
}
}
?>
</div>
this is the index.php
<?php include('header.php'); ?>
<body class="body" id="login">
<div class="container">
<div class="row-fluid">
<div class="span6"><div class="title_index"><?php include('title_index.php'); ?></div></div>
<div class="span6"><div class="pull-right"><?php include('login_admin.php'); ?></div></div>
</div>
<!-- <div class="row-fluid">
<div class="offset2">
<div class="span11"><div class="index-footer"><?php include('link.php'); ?></div></div>
</div>
</div> -->
<br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<?php include('footer.php'); ?>
</div>
<?php include('script.php'); ?>
</body>
</html>
this is the header.php
<!DOCTYPE html>
<html class="no-js">
<head>
<title>Church manager</title>
<meta name="description" content="Church manager">
<meta name="keywords" content="">
<meta charset="UTF-8">
<!-- Bootstrap -->
<!-- <link href="images/logo.png" rel="icon" type="image"> -->
<link href="images/JIL.jpg" rel="icon" type="image">
<link href="bootstrap/css/indexbg.css" rel="stylesheet" media="screen"/>
<link href="bootstrap/css/background.css" rel="stylesheet" media="screen">
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="bootstrap/css/bootstrap-responsive.css" rel="stylesheet" media="screen">
<link href="bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" media="screen">
<link href="bootstrap/css/font-awesome.css" rel="stylesheet" media="screen">
<link href="bootstrap/font-awesome-4.1.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="bootstrap/css/my_style.css" rel="stylesheet" media="screen">
<link href="bootstrap/css/print.css" rel="stylesheet" media="print">
<link href="vendors/easypiechart/jquery.easy-pie-chart.css" rel="stylesheet" media="screen">
<link href="assets/styles.css" rel="stylesheet" media="screen">
<link href="bootstrap/css/bootstrap.min1.css" rel="stylesheet" media="screen">
<link href="bootstrap/css/sb_admin.css" rel="stylesheet" media="screen">
<!-- HTmL5 shim, for IE6-8 support of HTmL5 elements -->
<!--[if lt IE 9]>
<![endif]-->
<!-- calendar css -->
<script src="bootstrap/js/html5.js"></script>
<link href="vendors/fullcalendar/fullcalendar.css" rel="stylesheet" media="screen">
<script src="vendors/jquery-1.9.1.min.js"></script>
<script src="vendors/modernizr-2.6.2-respond-1.1.0.min.js"></script>
<!-- data table -->
<link href="assets/DT_bootstrap.css" rel="stylesheet" media="screen">
<!-- notification -->
<link href="vendors/jGrowl/jquery.jgrowl.css" rel="stylesheet" media="screen">
<!-- wysiwug -->
<link rel="stylesheet" type="text/css" href="vendors/bootstrap-wysihtml5/src/bootstrap-wysihtml5.css"></link>
<script src="vendors/jGrowl/jquery.jgrowl.js"></script>
</head>
<?php include('lib/bcon.php');
dbcon();
?>
EDIT: New version of header.php:
<?php session_start();?>
<html class="no-js">
<head>
<title>Church manager</title>
<meta name="description" content="Church manager">
<meta name="keywords" content="">
<!-- Bootstrap -->
<!-- <link href="images/logo.png" rel="icon" type="image"> -->
<link href="images/JIL.jpg" rel="icon" type="image">
<link href="bootstrap/css/indexbg.css" rel="stylesheet" media="screen"/>
<link href="bootstrap/css/background.css" rel="stylesheet" media="screen">
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="bootstrap/css/bootstrap-responsive.css" rel="stylesheet" media="screen">
<link href="bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" media="screen">
<link href="bootstrap/css/font-awesome.css" rel="stylesheet" media="screen">
<link href="bootstrap/font-awesome-4.1.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="bootstrap/css/my_style.css" rel="stylesheet" media="screen">
<link href="bootstrap/css/print.css" rel="stylesheet" media="print">
<link href="vendors/easypiechart/jquery.easy-pie-chart.css" rel="stylesheet" media="screen">
<link href="assets/styles.css" rel="stylesheet" media="screen">
<link href="bootstrap/css/bootstrap.min1.css" rel="stylesheet" media="screen">
<link href="bootstrap/css/sb_admin.css" rel="stylesheet" media="screen">
<!-- HTmL5 shim, for IE6-8 support of HTmL5 elements -->
<!--[if lt IE 9]>
<![endif]-->
<!-- calendar css -->
<script src="bootstrap/js/html5.js"></script>
<link href="vendors/fullcalendar/fullcalendar.css" rel="stylesheet" media="screen">
<script src="vendors/jquery-1.9.1.min.js"></script>
<script src="vendors/modernizr-2.6.2-respond-1.1.0.min.js"></script>
<!-- data table -->
<link href="assets/DT_bootstrap.css" rel="stylesheet" media="screen">
<!-- notification -->
<link href="vendors/jGrowl/jquery.jgrowl.css" rel="stylesheet" media="screen">
<!-- wysiwug -->
<link rel="stylesheet" type="text/css" href="vendors/bootstrap-wysihtml5/src/bootstrap-wysihtml5.css"></link>
<script src="vendors/jGrowl/jquery.jgrowl.js"></script>
</head>
<?php
include('lib/bcon.php');
dbcon();
?>

remove this line from
if ($count > 0)
{
session_start(); // remove session here
$_SESSION['id']=$row['admin_id'];
header('location:dashboard.php');
}
In your header.php add session start line
<?php session_start();?>
This must be very first line before start of html

Related

"Unexpected end of file" error in perfectly error-free PHP file with custom router.php

Currently I am using PHP's built in web server, and I recently started using a custom router script so that I can effectively implement a custom 404 page. Here is router.php:
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
chdir($root);
$path = '/'.ltrim(parse_url($_SERVER['REQUEST_URI'])['path'],'/');
set_include_path(get_include_path().':'.__DIR__);
if(file_exists($root.$path))
{
if(is_dir($root.$path) && substr($path,strlen($path) - 1, 1) !== '/')
$path = rtrim($path,'/').'/index.php';
if(strpos($path,'.php') === false) return false;
else {
chdir(dirname($root.$path));
require_once $root.$path;
}
}else include_once 'pages/404.php';
However, I have a login page that uses PHP to... login, of course. However, using this router.php, the login page gives me the usual "[website] cannot handle your request" and the logs say Unexpected end of file. The code worked just fine until now (and passes many syntax checkers), so I suspect either my router.php somehow isn't fit to run proper PHP files, or it's messing with how said files are handled.
Heres my login PHP:
<?php
$user = $_POST['username'];
$pass = $_POST['pass'];
$return = $_GET['return'];
if (!isset($_GET['return']))
{
echo "<span>No return page is selected to return to, please go back to the <a href='../'>Home page</a> and go to a different page.</span>";
}
if($user == "adminuser"
&& $pass == "adminpass")
{
include("../pages/" . $return . "/secret/secure.php");
}
else
{
if(isset($_POST))
{?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Login V6</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--===============================================================================================-->
<link rel="icon" type="image/png" href="images/favicon.ico"/>
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="fonts/font-awesome-4.7.0/css/font-awesome.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="fonts/iconic/css/material-design-iconic-font.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/animate/animate.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/css-hamburgers/hamburgers.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/animsition/css/animsition.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/select2/select2.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/daterangepicker/daterangepicker.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="css/util.css">
<link rel="stylesheet" type="text/css" href="css/main.css">
<!--===============================================================================================-->
</head>
<body>
<div class="limiter">
<div class="container-login100">
<div class="wrap-login100 p-t-85 p-b-20">
<form class="login100-form validate-form" method="POST" action="index.php?monster=<?php echo $monster ?>">
<span class="login100-form-title p-b-70">
Welcome
</span>
<span class="login100-form-avatar">
<img src="images/logo.png" alt="AVATAR">
</span>
<input type="hidden" name="monster" value="<?php $_GET['monster'];?>">
<div class="wrap-input100 validate-input m-t-85 m-b-35" data-validate = "Enter username">
<input class="input100" type="text" name="username">
<span class="focus-input100" data-placeholder="Username"></span>
</div>
<div class="wrap-input100 validate-input m-b-50" data-validate="Enter password">
<input class="input100" type="password" name="pass">
<span class="focus-input100" data-placeholder="Password"></span>
</div>
<div class="container-login100-form-btn">
<input class="login100-form-btn" type="submit" name="submit" value="Login"></input>
</div>
<ul class="login-more p-t-190">
<li class="m-b-8">
<span class="txt1">
Forgot
</span>
<a href="../index.html#contact" class="txt2">
Username / Password?
</a>
</li>
</ul>
</form>
</div>
</div>
</div>
<div id="dropDownSelect1"></div>
<!--===============================================================================================-->
<script src="vendor/jquery/jquery-3.2.1.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/animsition/js/animsition.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/bootstrap/js/popper.js"></script>
<script src="vendor/bootstrap/js/bootstrap.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/select2/select2.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/daterangepicker/moment.min.js"></script>
<script src="vendor/daterangepicker/daterangepicker.js"></script>
<!--===============================================================================================-->
<script src="vendor/countdowntime/countdowntime.js"></script>
<!--===============================================================================================-->
<script src="js/main.js"></script>
</body>
</html>
<?}
}
?>
I know next to nothing about the science behind PHP routers (and I got mine from a stackoverflow answer), so if something in my router.php is painfully wrong, well, that's why :/
Try to add php to <? in Your login.php:
</body>
</html>
<?}<- this one
}
?>

Layout don't keep when printing page Zend Framework 2 Bootstrap

I need to print the following page :
But the result is not as expected :
It seems like my bootstrap css is not used when I print the webpage.
This is the HTML code of my page :
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Route Du Drive</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Le styles -->
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700&subset=all" media="screen" rel="stylesheet" type="text/css">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" media="screen" rel="stylesheet" type="text/css">
<link href="/metronic/global/plugins/simple-line-icons/simple-line-icons.min.css" media="screen" rel="stylesheet" type="text/css">
<link href="/metronic/global/plugins/bootstrap/css/bootstrap.min.css" media="screen" rel="stylesheet" type="text/css">
<link href="/metronic/global/plugins/bootstrap-switch/css/bootstrap-switch.min.css" media="screen" rel="stylesheet" type="text/css">
<link href="/img/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon">
<link href="/metronic/global/css/components-md.min.css" media="screen" rel="stylesheet" type="text/css">
<link href="/metronic/global/css/plugins-md.min.css" media="screen" rel="stylesheet" type="text/css">
<link href="/metronic/pages/css/login-4.min.css" media="screen" rel="stylesheet" type="text/css">
<link href="/css/global.css" media="screen" rel="stylesheet" type="text/css">
<!-- Scripts -->
</head>
<body cz-shortcut-listen="true">
<header>
</header>
<div class="row">
<div class="col-xs-1"></div>
<div class="col-xs-3">
<h3>Commande N°O001</h3>
<h4>Boulangerie Ange Oceanis</h4>
<h4>1 Rue de la Côte de Nacre</h4>
<h4>44600 Saint-Nazaire</h4>
</div>
<div class="col-xs-1"></div> <div class="col-xs-3"><h3>Commande archivée</h3></div>
<div class="col-xs-3">
<h3>Nom du client</h3>
</div>
</div>
<div class="row">
<div class="col-xs-1"></div>
<div class="col-xs-10">
<h3 class="text-center">Articles commandés</h3>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Check</th>
<th>Référence</th>
<th>Dénomination</th>
<th>Prix unitaire</th>
<th>Quantité</th>
<th>Cout</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td>PAIN</td>
<td>Baguette de pain</td>
<td>0.93 €</td>
<td>9</td>
<td>8.37 €</td>
</tr>
<tr>
<td colspan="4"></td>
<td><b>Total commande</b></td>
<td>8.37 €</td>
</tr>
</tbody>
</table>
<i class="fa fa-arrow-left" aria-hidden="true"></i> Retour à la page précédente
</div>
<script type="text/javascript" src="/js/jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="/js/global.js"></script>
<script type="text/javascript" src="/metronic/global/plugins/bootstrap/js/bootstrap.js"></script>
<script type="text/javascript" src="/metronic/global/plugins/js.cookie.min.js"></script>
<script type="text/javascript" src="/metronic/global/plugins/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<script type="text/javascript" src="/metronic/global/plugins/jquery.blockui.min.js"></script>
<script type="text/javascript" src="/metronic/global/plugins/bootstrap-switch/js/bootstrap-switch.min.js"></script>
<script type="text/javascript" src="/metronic/global/plugins/backstretch/jquery.backstretch.min.js"></script>
<script type="text/javascript" src="/metronic/global/scripts/app.min.js"></script>
How can I print the page with the original styling?
Does someone have an idea what is causing the problem?
Try to locate the following line:
<link href="/metronic/global/plugins/bootstrap/css/bootstrap.min.css" media="screen" rel="stylesheet" type="text/css">
and change it to
<link href="/metronic/global/plugins/bootstrap/css/bootstrap.min.css" media="all" rel="stylesheet" type="text/css">
The changes is on the media="screen" to media="all". This change will ensure that the same styling for both displaying the page on the screen as well as on your print.
Read more on the media attribute here or here on MDN.

How to set checkbox checked and unchecked event using JQUERY

I want to Prompt Yes message if Checkbox is checked.
And want to Prompt No message if checkbox is Unchecked.
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/titatoggle/1.2.11/titatoggle-dist.css" >
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<link rel="stylesheet" href="dist/css/bootstrap-select.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="dist/js/bootstrap-select.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<div class="... checkbox-slider--b-flat checkbox-slider-md col-md-4" style="margin-top: 22px; margin-left: 53px;" id="with_answer">
<label>
<input type="checkbox"><span>Answer</span>
</label>
</div>
</body>
</html>
You can use jQuery's change event, you can do it like this:
$(function() {
$('.checkbox').on('change', function(e) {
if($(this).is(':checked')) {
alert('Yes')
} else {
alert('No')
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
<input class="checkbox" type='checkbox'> Checkbox
</div>
For your code, the code should go like this:
$(function() {
$('.myCheckbox').on('change', function(e) {
if($(this).is(":checked")) {
alert('checked');
} else {
alert('unchecked');
}
});
});
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/titatoggle/1.2.11/titatoggle-dist.css" >
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<link rel="stylesheet" href="dist/css/bootstrap-select.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="dist/js/bootstrap-select.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<div class="... checkbox-slider--b-flat checkbox-slider-md col-md-4" style="margin-top: 22px; margin-left: 53px;" id="with_answer">
<label>
<input class="myCheckbox" type="checkbox"><span>Answer</span>
</label>
</div>
</body>
</html>
Hope this helps!
You are after the change event. Bind a listener to the change event and then you can check the this.checked to see if it is true/false to perform your desired logic.

Issue with bloginfo('stylesheet_url') in wordpress

Here is my header.php links.when i enter bloginfo('stylesheet_url') for style.css after running page showing blank sceen.
<link href="http://fonts.googleapis.com/css?family=Lato:300,400,400italic,600,700|Raleway:300,400,500,600,700|Crete+Round:400italic" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo('stylesheet_url');?>" />
<link rel="stylesheet" href="css/bootstrap.css" type="text/css" />
<!--<link rel="stylesheet" href="style.css" type="text/css" />-->
<link rel="stylesheet" href="css/dark.css" type="text/css" />
<link rel="stylesheet" href="css/font-icons.css" type="text/css" />
<link rel="stylesheet" href="css/animate.css" type="text/css" />
<link rel="stylesheet" href="css/magnific-popup.css" type="text/css" />
<link rel="stylesheet" href="css/responsive.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
Please try "get_template_directory_uri()" function for get url. Like below
<link href="<?php echo get_template_directory_uri(); ?>/css/style.css" rel="stylesheet">

Php Form doesn't sends mysql_query to a database

So my PHP Form doesn't sends any information to the database though
there is a connection to the database!I checked everything couple of
times but it still doesn't work.
Any Ideas where i have a problem in my code? Would be very appreciative for any help!
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Add your business website description here">
<meta name="keywords" content="Add your, business, website, keywords, here">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!-- favicon -->
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<!-- google fonts -->
<link href='http://fonts.googleapis.com/css?family=Raleway:400,500,600,700,800,900%7CMerriweather:400,400italic,300,300italic,700,700italic' rel='stylesheet' type='text/css'>
<!-- Font icons -->
<link rel="stylesheet" href="css/vendor/elegant-font-icon.css">
<!-- stylesheet -->
<link rel="stylesheet" href="css/vendor/bootstrap.css">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/custom.css">
<link rel="stylesheet" href="css/vendor/animate.css">
<link rel="stylesheet" href="css/vendor/owl.carousel.css">
<!-- style switcher -->
<link rel="stylesheet" href="css/vendor/style-switcher.css">
<!-- Custom styles for this template -->
<link rel="stylesheet" type="text/css" href="css/colors/blue.css" title="blue" media="screen"/>
<link rel="stylesheet" type="text/css" href="css/colors/blue-2.css" title="blue-2" media="screen"/>
<link rel="stylesheet" type="text/css" href="css/colors/purple.css" title="purple" media="screen"/>
<link rel="stylesheet" type="text/css" href="css/colors/green.css" title="green" media="screen"/>
<link rel="stylesheet" type="text/css" href="css/colors/green-2.css" title="green-2" media="screen"/>
<link rel="stylesheet" type="text/css" href="css/colors/yellow.css" title="yellow" media="screen"/>
<link rel="stylesheet" type="text/css" href="css/colors/orange.css" title="orange" media="screen"/>
<link rel="stylesheet" type="text/css" href="css/colors/red.css" title="red" media="screen"/>
<link rel="stylesheet" type="text/css" href="css/colors/red-2.css" title="red-2" media="screen"/>
<link rel="stylesheet" type="text/css" href="css/colors/red-3.css" title="red-3" media="screen"/>
<link rel="stylesheet" type="text/css" href="css/colors/pink.css" title="pink" media="screen"/>
<link rel="stylesheet" type="text/css" href="css/colors/pink-2.css" title="pink-2" media="screen"/>
<link rel="stylesheet" type="text/css" href="css/colors/beige.css" title="beige" media="screen"/>
<link rel="stylesheet" type="text/css" href="css/colors/midnight.css" title="midnight" media="screen"/>
<link rel="stylesheet" type="text/css" href="css/colors/black.css" title="black" media="screen"/>
<script type="text/javascript" src="js/vendor/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="js/vendor/modernizr.custom.js"></script>
<!--[if lt IE 9]>
<script type="text/javascript" src="js/vendor/html5-3.6-respond-1.1.0.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<fieldset id="contactform" class="wow bounce" data-wow-duration="2s" data-wow-delay="0.5s">
<form action="http://xxxxx.com/forma.php " method="POST">
<div id="form_result"></div>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<input name="name" type="text" id="name" class="form-control" placeholder="Your Name">
</div>
</div>
<div class="row">
<div class="col-md-3 col-md-offset-3">
<input name="email" type="text" id="email" class="form-control" value="" placeholder="Your email">
</div>
<div class="col-md-3">
<input name="phone" type="text" id="phone" class="form-control" value="" placeholder="Your Number">
</div>
</div>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<textarea name="message" cols="40" rows="5" id="comments" class="form-control" placeholder="Your Message"></textarea>
</div>
</div>
<div class="row">
<div class="col-md-12 text-center">
<button type="submit" class="btn btn-default btn-lg" id="submit">SUBMIT</button>
</div>
</div>
</form>
</fieldset>
</div>
</body>
</html>
<?php
$a=mysql_connect('xxxx','xxxx','xxxx');
$b=mysql_select_db('xxxxx',$a);
if (!$b){
echo 'no connection db ';
}
if ($_POST['submit']) {
mysql_query('INSERT INTO form SET name="'.$_POST['name'].'",email="'.$_POST['email'].'",phone='.$_POST['phone'].',message="'.$_POST['message'].'"');
}
?>
You forgot the name attribute. Change:
<button type="submit" class="btn btn-default btn-lg" id="submit">SUBMIT</button>
To:
<button type="submit" class="btn btn-default btn-lg" name="submit" id="submit">SUBMIT</button>
<button type="submit" class="btn btn-default btn-lg" name="add" id="submit">SUBMIT</button>
and give the condition
if (isset($_POST['add'])) {
mysql_query('INSERT INTO form SET name="'.$_POST['name'].'",email="'.$_POST['email'].'",phone='.$_POST['phone'].',message="'.$_POST['message'].'"');
}
Add attribute name.
<button type="submit" class="btn btn-default btn-lg" name="submit" id="submit">SUBMIT</button>
then use
if (isset($_POST['submit'])) {
mysql_query('INSERT INTO form SET name="'.$_POST['name'].'",email="'.$_POST['email'].'",phone='.$_POST['phone'].',message="'.$_POST['message'].'"');
}
mysql_query() sends a unique query (multiple queries are not supported) to the currently active database on the server that's associated with the specified link_identifier.

Categories