JQuery validate within a Twitter Bootstrap modal with PHP - php

I'm working on a transport planner and in my tasks table I have a button to sign a routenumber to a task. When a task haven't got a routenumber at all, the button will call a bootstrap modal to assign a new routenumber to that task which will also be the standard routenumber.
When a task already has a routenumber, the button will call the same modal with a new checkbox added. Unchecked means, change the routenumber only today, checked means, make the inserted routenumber the standard routenumber.
I'm using JQuery for the validation but nothings happend and the form is submitted without validation. What am I doing wrong..?
LINK TO CALL THE MODAL:
<?php if ($row['routenummer'] != ''){ echo $row['routenummer']; } if ($row['routenummer'] == ''){ ?><i class="icon-plus"></i><?php }?>
MODAL:
<div id="routenummer_view<?php echo $row['planning_id']?>" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="routenummer_viewLabel" aria-hidden="true">
<form class="modal-form" action="../includes/modals/routenummer/submit_view_routenummer.php"
data-remote="true" method="post" id="routenummer_edit">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="routenummerviewLabel"><?php if ($row['routenummer'] == ''){ echo 'Standaard Routenummer Invoeren';} else echo 'Routenummer Wijzigen';?></h3>
</div>
<div class="modal-body">
<label>Routenummer:</label>
<input type="text" name="routenummer" <?php if ($row['routenummer'] != NULL){ ?>value="<?php if ($row['routenummer'] != NULL){ echo $row['routenummer']; echo '" /><br />';}?> <?php } if ($row['routenummer'] == NULL){ ?> placeholder="Typ hier een routenummer..." /><?php if ($row['routenummer'] != NULL){ echo '<br />'; }}?>
<?php if ($row['routenummer'] != NULL){ ?>
<label class="checkbox">
<input type="checkbox" name="standaard"> Maak standaard routenummer.</label>
<?php }?>
</div>
<div class="modal-footer">
<input type="hidden" name="opdrachtid" value="<?php echo $row['planning_id']; ?>" />
<input type="submit" value="<?php if ($row['routenummer'] == ''){ echo 'Invoeren';} else echo 'Wijzigen';?>" class="btn btn-primary" />
Annuleren
</div>
</form>
</div>
JQUERY:
$(document).ready(function() {
$("#routenummer_edit").validate({
onkeyup : false,
rules : {
routenummer : {
required : true,
digits: true
}
},
messages : {
routenummer : {
required : "Routenummer is verplicht.",
digits : "Routenummer moet een getal zijn."
}
},
});
});
EXAMPLE IMAGE
EDIT
RENDERED HTML
When a task doesn't have a standard routenumber:
<div id="routenummer_view90" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="routenummer_viewLabel" aria-hidden="true">
<form class="modal-form" action="../includes/modals/routenummer/submit_view_routenummer.php"
data-remote="true" method="post" id="routenummer_edit">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="routenummerviewLabel">Standaard Routenummer Invoeren</h3>
</div>
<div class="modal-body">
<label>Routenummer:</label>
<input type="text" name="routenummer" placeholder="Typ hier een routenummer..." />
</div>
<div class="modal-footer">
<input type="hidden" name="opdrachtid" value="90" />
<input type="submit" value="Invoeren" class="btn btn-primary" />
Annuleren
</div>
</form>
</div>
When a task does have a standard routenumber:
<div id="routenummer_view67" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="routenummer_viewLabel" aria-hidden="true">
<form class="modal-form" action="../includes/modals/routenummer/submit_view_routenummer.php"
data-remote="true" method="post" id="routenummer_edit">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="routenummerviewLabel">Routenummer Wijzigen</h3>
</div>
<div class="modal-body">
<label>Routenummer:</label>
<input type="text" name="routenummer" value="21" /><br /> <label class="checkbox">
<input type="checkbox" name="standaard"> Maak standaard routenummer.</label>
</div>
<div class="modal-footer">
<input type="hidden" name="opdrachtid" value="67" />
<input type="submit" value="Wijzigen" class="btn btn-primary" />
Annuleren
</div>
</form>
</div>
EDIT
$(document).ready(function() {
$('.modal-form').each(function () {
$(this).validate({ // initialize the plugin
rules: {
routenummer: {
required: true,
digits: true
}
},
messages : {
routenummer : {
required : "Routenummer is verplicht.",
digits : "Routenummer moet een getal zijn."
}
}
});
});
});
EDIT
MODAL
<div id="routenummer<?php echo $row['planning_id']?>" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="routenummerLabel" aria-hidden="true">
<form class="modal-form" action="../includes/modals/routenummer/submit_routenummer.php"
data-remote="true" method="post">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="routenummerLabel"><?php if ($row['routenummer'] == ''){ echo 'Standaard Routenummer Invoeren';} else echo 'Routenummer Wijzigen';?></h3>
</div>
<div class="modal-body">
<label>Routenummer:</label>
<input type="text" name="routenummer" <?php if ($row['routenummer'] != NULL){ ?>value="<?php if ($row['routenummer'] != NULL){ echo $row['routenummer']; echo '" /><br />';}?> <?php } if ($row['routenummer'] == NULL){ ?> placeholder="Typ hier een routenummer..." /><?php if ($row['routenummer'] != NULL){ echo '<br />'; }}?>
<?php if ($row['routenummer'] != NULL){ ?>
<label class="checkbox">
<input type="checkbox" name="standaard"> Maak standaard routenummer.</label>
<?php }?>
</div>
<div class="modal-footer">
<input type="hidden" name="opdrachtid" value="<?php echo $row['planning_id']; ?>" />
<input type="submit" value="<?php if ($row['routenummer'] == ''){ echo 'Invoeren';} else echo 'Wijzigen';?>" class="btn btn-primary" />
Annuleren
</div>
</form>
</div>

Validation is working as intended in both of your examples...
Your "When a task doesn't have a standard routenumber" example is working:
http://jsfiddle.net/qdX8y/1/
(Validation will not allow submission of an empty field)
Your "When a task does have a standard routenumber" example is also working. However, it passes validation immediately because you already have a value in the field that meets the requirements of the compound rule, required and digits.
<input type="text" name="routenummer" value="21" />
Removing value="21" causes a validation message to be triggered.
http://jsfiddle.net/qdX8y/
EDIT:
As per comments on OP, it was discovered that the OP has multiple form elements sharing the same id. Not only is this invalid HTML, but it breaks the Validate plugin since it does not know which form to target.
However, all form elements can share the same class name and then you can use a jQuery .each() to select them all. This example contains five duplicate <form> elements, each with class="myform" and assumes all five form elements share the same .validate() options.
$(document).ready(function () {
$('.myform').each(function () {
$(this).validate({ // initialize the plugin on each form
// your options and rules
});
});
});
DEMO: http://jsfiddle.net/cWtd6/

Related

internal server error 500 with jquery.min.js

I am a novice to PHP. Now I am building a simple login-logout system. While trying to log in the system, I got the Internal Server Error with jquery.min.js:4. Here is my code:
Index:
<!-- Login Form -->
<form method="post" id="loginForm">
<div class="modal fade" id="login" tabindex="-1" role="dialog" aria-labelledby="#loginHeading" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="loginHeading">Login Form</h4>
</div>
<div class="modal-body">
<div id="loginMessage"></div>
<div class="form-group">
<label for="email">Email: </label>
<input type="email" id="email" name="email" class="form-control" required>
</div>
<div class="form-group">
<label for="pass">Password: </label>
<input type="password" id="pass" name="pass" class="form-control" required>
</div>
<div class="row">
<div class="checkbox" >
<div class="pull-left" style="padding-left:20px">
Forget password?
</div>
<label class="pull-right" style="padding-right:20px"><input type="checkbox" name="remember" value=""> Remember me</label>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-success pull-left" data-dismiss="modal" data-toggle="modal" data-target="#signUp">Register</button>
<button type="submit" class="btn myBtn">Login</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
Script:
$("#loginForm").submit(function(event) {
event.preventDefault();
var dataPost= $(this).serializeArray();
$.ajax({
url: '4-logIn.php',
type: 'POST',
data: dataPost,
success:function(data){
if (data == "success") {
window.location("mainPageLogin.php");
}
else {
$("#loginMessage").html(data);
}
},
error: function(data){
$('#loginMessage').html('<div class="alert alert-danger"><h5>Error in connection with loginForm</h5></div>');
}
});
});
4-login.php:
``
<?php
session_start();
include '0-connection.php';
$error='';
$email=filter_var($_POST["email"],FILTER_SANITIZE_EMAIL);
$pass=filter_var($_POST["pass"],FILTER_SANITIZE_STRING);
// Query
$email=mysqli_real_escape_string($link,$email);
$pass=mysqli_real_escape_string($link,$pass);
$pass=hash('sha256',$pass);
$sql="SELECT * FROM users WHERE email='$email' AND password='$pass' AND activation='activated'";
$result=mysqli_query($link, $sql);
if (!$result) {
echo "<div class='alert alert-danger'>Error running the query to take user login</div>";
exit;
}
$count= mysqli_num_rows($result);
if ($count !== 1) {
$error="<div class='alert alert-danger'><strong>ERROR:</strong> Wrong username or password. Please try again or Do you want to <a href='#' data-dismiss='modal' data-target='#signUp' data-toggle='modal'>Sign up</a></div>";
echo $error;
}
else {
// Set session
$row=mysqli_fetch_array($result, MYSQLI_ASSOC);
$_SESSION['user_id']=$row['user_id'];
$_SESSION['username']=$row['username'];
$_SESSION['email']=$row['email'];
// Check remember me Box
if (empty($_POST['remember'])) {
echo "success";
}
else {
}
}
?>
This is my error:
demonstration
web response
Please be more specific in your answer because I am very new in programming. Thanks for reading.
Error in 4-logIn.php, if (!result) { must be changed as if (!$result) {

How can I show a variable in Bootstrap modal in PHP?

I have a form that makes a calculation, enter the database and returns the value through an alert.
I would like to replace this alert for modal.
HTML
<form method="post" action="#">
<input type="text" name="alt" id="altura" required><br><br>
<input type="text" name="peso" id="peso" required><br><br>
<button type="submit" id="Send">Send</button>
</form>
PHP
function calcularIMC($altura,$peso){
$imc = 0;
if($altura >0 && $peso >0){
$imc = $peso / ($altura * $altura);
}
echo '<script>';
echo 'alert("'.$imc.'");';
echo '</script>';
}
I tried as follows:
- Added the php after the tag </html> code;
- Added the variable responsible for the calculation: $imc;
- I linked the button Send with modal.
<form method="post" action="#">
<input type="hidden" name="acao" id="acao" value="cadastrar"/>
<input type="text" name="alt" id="altura" required><br><br>
<input type="text" name="peso" id="peso" required><br><br>
<button type="submit" id="Enviar" data-toggle="modal" data-target="#myModal">Enviar</button>
</form>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
<?php echo'.$imc.';?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</body>
</html>
PHP
<?php
function calcularIMC($altura,$peso){
$imc = 0;
if($altura >0 && $peso >0){
$imc = $peso / ($altura * $altura);
}
return $imc;
}
?>
Thus, when I click on Send button (with all the empty fields), it opens the modal and displays the '.$imc.' as String.
When I insert the data and click on the button Send a dims window (early effect of modal) and quickly back to normal. I believe the modal is being called, but some stretch it gives erros and closes.
How can I solve this?
AJAX, top of code:
<?php
$imc = false;
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$imc = calcularImc($_POST['altura'], $_POST['peso']);
}
?>
End of body
<?php
if ($imc !== false){
echo "<script>$('#myModal').modal('show');</script>";
}
?>
Would it be this? I tried to add this code, but gave the same result. By submitting the form, the window dims and quickly back to normal.
---------------------------------UPDATED / I MANAGED TO DO THAT I WANTED-------------------------------
<form method="post" action="#">
<input type="text" name="alt" id="altura" required><br><br>
<input type="text" name="peso" id="peso" required><br><br>
<button type="submit" id="Send" data-toggle="modal" data-target="#myModal">Send</button>
</form>
<?php
$imc = false;
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$imc = calcularImc($_POST['altura'], $_POST['peso']);
}
?>
<?php
if ($imc !== false){
echo '<script src="https://code.jquery.com/jquery-2.2.3.min.js"></script>';
echo '<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>';
echo "<script>$('#myModal').modal('show');</script>";
}
?>
</body>
</html>
function calcularIMC($altura,$peso){
$imc = 0;
if($altura >0 && $peso >0){
$imc = $peso / ($altura * $altura);
}
echo '<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">';
echo $imc; // RESULT OF CALC MODAL INSIDE
echo '</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>';
}
?>
POST Method:
<?php
function calcularIMC($altura,$peso){
$imc = 0;
if($altura >0 && $peso >0){
$imc = $peso / ($altura * $altura);
}
return $imc;
}
$imc = "";
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$imc = calcularImc($_POST['alt'], $_POST['peso']);
?>
<script type="text/javascript">
$(window).load(function(){
$('#myModal').modal('show');
});
</script>
<?php
}
?>
<form method="post" action="#">
<input type="hidden" name="acao" id="acao" value="cadastrar"/>
<input type="text" name="alt" id="altura" required><br><br>
<input type="text" name="peso" id="peso" required><br><br>
<button type="submit" id="Send">Send</button>
</form>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
<?php echo $imc;?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</body>
</html>
Errors you made:
Addres altura as $_POST['altura'] instead of $_POST['alt'] (as its name attribute is alt)
You started your modal.show script before the page was loaded. So the modal might not exist yet. Wrap it in $(window).load(function(){})
Printed the variable in the wrong way: echo'.$imc.' should have been echo $imc;
Even nicer would be to use AJAX. Then you don't have to refresh the page. If you want to do that, lookup AJAX. You could also avoid using PHP. #AceWebDesign Answer explains nicely how this can be done without PHP.
You could use jQuery for this.
instead of
echo '<script>';
echo 'alert("'.$imc.'");';
echo '</script>';
You could use this on the page. It may need some tweaking as it was quick and rough, and the modal was a little rusty.
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<form method="post" action="#">
<input type="hidden" name="acao" id="acao" value="cadastrar"/>
<input type="text" name="alt" id="altura" required><br><br>
<input type="text" name="peso" id="peso" required><br><br>
<button type="submit" id="Enviar" data-toggle="modal" data-target="#myModal">Enviar</button>
</form>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function() {
$(document).off("click", ".btn-default").on( "click", ".btn-default", function(e) {
var altura = $('#altura').val();
var peso = $('#peso').val();
var imc =0;
if (altura > 0 )
{
var imc = peso / (altura * altura);
}
$(".modal-body").html(imc);
$('#myModal').modal('show');
});
return false;
});
</script>
</body>
</html>

Reload Bootstrap Modal on PHP variable not valid

Having some problems with the error handling of a bootstrap modal. In the modal I have two inputs (both are required). I want to be able to display a simple "required" message if the form is submitted without one of the fields populated.
I tried doing this with PHP and it works in a page by itself, but when I put it in a modal the modal closes on submit and then if you re-open the modal you see the error messages. I really want the modal to stay open or re-open if the input fields are not valid when the user submits.
Any help would be appreciated! Thanks!
HTML (Start of the modal):
<div class="modal fade" id="createModal" tabindex="-1" role="dialog" aria-labelledby="createModal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Add a vCenter</h4>
</div>
<div class="modal-body">
PHP (To graph the input and report any errors):
if ( !empty($_POST)) {
// keep track validation errors
$vcenternameError = null;
$vcenterownerError = null;
// keep track post values
$vcentername = $_POST['vcentername'];
$vcenterowner = $_POST['vcenterowner'];
// validate input
$valid = true;
if (empty($vcentername)) {
$vcenternameError = 'Please enter vCenter Name';
$valid = false;
}
if (empty($vcenterowner)) {
$vcenterownerError = 'Please select vCenter Owner';
$valid = false;
}
// insert data
if ($valid) {
$sql = "INSERT INTO ";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt === false) {
die( print_r( sqlsrv_errors(), true) );
}
header("Location: index.php");
}
}
?>
HTML (the rest of the modal):
<div class="panel-body">
<form class="form-horizontal" action="index.php" method="post">
<div class="<?php echo !empty($vcenternameError)?'error':'';?> form-group">
<div class="alert alert-warning">
Please input the FQDN of the vCenter and select an owner.
</div>
<label class="control-label">vCenter Name</label>
<div class="controls">
<input name="vcentername" type="text" placeholder="vCenter Name" value="<?php echo !empty($vcentername)?$vcentername:'';?>" class="form-control">
<?php if (!empty($vcenternameError)): ?>
<div class="alert alert-warning alert-dismissable">
<?php echo $vcenternameError;?>
</div>
<?php endif; ?>
</div>
</div>
<div class="<?php echo !empty($vcenterownerError)?'error':'';?> form-group">
<label class="control-label">vCenter Owner</label>
<div class="controls">
<div class="btn-group" data-toggle="button" role="group" aria-label="...">
<label class="btn btn-default">
<input type="radio" name="vcenterowner" value="Team1"> Team1
</label>
<label class="btn btn-default">
<input type="radio" name="vcenterowner" value="Team2"> Team2
</label>
<label class="btn btn-default">
<input type="radio" name="vcenterowner" value="Team3"> Team3
</label>
</div>
<?php if (!empty($vcenterownerError)): ?>
<div class="alert alert-warning alert-dismissable">
<?php echo $vcenterownerError;?>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<div class="form-actions">
<button type="submit" class="btn btn-success">Add</button>
<a class="btn btn-default" href="index.php">Back</a>
</div>
</form>
</div>
</div>
</div>
</div>
You can use jQuery to open the modal again if the modal contains errors when the page loads:
var modal = $('#createModal');
if(modal.find('div.alert-warning').length)
modal.modal();
But for the best user experience, you should call your PHP script with an ajax request: http://api.jquery.com/jquery.ajax/

Why can't I POST data from a Modal to PHP?

Using the following code, a modal within a form with method="POST" but in the php-part the submitted value is not read. Can anyone tell me how to accomplish this?
<?php
if ($error) {
echo '<div class="alert alert-danger">'.$error.'</div>';
}
if ($message) {
echo '<div class="alert alert-success">'.$message.'</div>';
}
?>
<div class="container">
<button class="btn btn-success" data-toggle="modal" data-target="#myModal">
Launch modal
</button>
<form method="post">
<div class="modal" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">You will receive an Access Code at your new email-address</h4>
</div>
<div class="modal-body">
<label for="text">Fill in your Access Code right here</label>
<input type="text" name="AccessCode" class="form-control"/>
</div>
<div class="modal-footer">
<input type="submit" name="submit" value="Confirm" data-dismiss="modal" class="btn btn-success btn-lg marginTop" />
</div>
</div>
</div>
</div>
</form>
</div>
The php part looks like this:
<?php
if ($_POST['submit']=='Confirm') {
print_r($_POST);
$error="No errors";
$message="Approved!";
} else {
$error="Error!";
$message="Nothing received";
}
?>
Form needs an action ..
<form method="post">
Has no idea where it is supposed to post the information to.
<form method="post" action="phpPageToSendTo.php">
will work..
To test, at the top of your page in the php section add in
$testValue = "";
if(isset($_POST["AccessCode"]))
{
$testValue = $_POST["AccessCode"] ;
echo "<h1> BIG LETTERS WITH THE ACCESS CODE :" . $testValue . "</h1>";
}
?>
Now in your form HTML item use the action="" Run the page and test the form.
Resolution :
And it seems you cannot have another event attached to your submit.. data-dismiss="modal".

Twitter's bootstrap Form inside Modal

I'm using twitter's bootstrap to make a WebApp, on one of the features of the App I need to have some modals with form's inside. Those forms will be filled with data through some PHP scripts. I'm having problems using the modal feature with forms, the data for edition is correctly displayed in the fields, but I'can't seem to submit the form.
This is my code:
<a href="#edit_user_<?php echo $row['id_user'] ?>" role='button' data-toggle='modal' data-original-title='Edit User' class='btn btn-small btn-info time-link'><i class='icon-pencil icon-white'></i></a>
<button data-toggle='tooltip' data-original-title='Delete User' class='btn btn-small btn-danger time-link'><i class='icon-trash icon-white'></i></button>
<?php
echo "</td>";
echo "</tr>";?>
<div id="edit_user_<?php echo $row['id_user']; ?>" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Modal header</h3>
</div>
<div class="modal-body">
<form action="" method="POST">
<label for="name">Name</label>
<input type="text" name="name" value="<?php echo $row['name']?>"/>
<label for="email">Email</label>
<input type="text" name="email" value="<?php echo $row['email']?>">
<button type="submit" name="update_btn">Submit</button>
<?php
if (isset($_POST['update_btn'])) {
if (isset($_POST['name']) && $_POST['name'] !="") {
if (isset($_POST['email']) && $_POST['email'] !="") {
$qstr_updateuser = "UPDATE `host_register`.`users` SET `name`=".$_POST['name'].", `email`= ".$_POST['email']." WHERE `users`.`id_user` = ".$row['id_user']."";
echo $qstr_updateuser;
$update_user = mysqli_query($dbc,$qstr_updateuser);
}
}
}?>
</form>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary">Save changes</button>
</div>
</div>
And for some reason I can't understand, the browser output's this:
<div class="modal-body">
<form method="POST" action=""></form>
<label for="name">Name</label>
<input type="text" value="Pedro Oliveira" name="name">
<label for="email">Email</label>
<input type="text" value="pedro.oliveira#est.pt" name="email">
<button name="update_btn" type="submit">Submit</button>
</div>
I'm kind of clueless here! Is it a problem with bootstrap or with my code?
Fortunately, I found out that, since the Modal was inside a tag because of a while loop was causing this disturbance, but I could quite understand why that was happening. Fortunately I restarted my work from scratch and decided to create a different while loop to do the same Job, as it seems the problem was really the table tag.
If browser output's is that, you can't submit because submit button is not inside the form tag, even the inputs. Unless that your problem is really that.

Categories