0
Good evening, folks, I have a question about modal. I have an address confirmation form, but I sent my data via bank, so far so good, the problem is: I wonder when I click the button confirm how I do to return me a modal "Your order has been registered"?
Ordering.php clients.
<form action="connectpedido.php" id="contact_form" class="contact-form" method="post">
<ul class="row">
<li class="col-sm-12">
<label>
<input type="text" class="form-control" name="cliente_nome" id="nome" placeholder="Nome *" x-moz-errormessage="campo obrigatório" required />
</label>
</li>
<li class="col-sm-6">
<label>
<input type="text" class="form-control" name="cliente_email" id="email" placeholder="E-mail *" required x-moz-errormessage="campo obrigatório" />
</label>
</li>
<li class="col-sm-6">
<label>
<input type="text" class="form-control" name="cliente_telefone" id="telefone" placeholder="Telefone *" required x-moz-errormessage="campo obrigatório" />
</label>
</li>
<li class="col-sm-6">
<label>
<input type="text" class="form-control" name="cliente_bairro" id="bairro" placeholder="Bairro *" required x-moz-errormessage="campo obrigatório" />
</label>
</li>
<li class="col-sm-6">
<label>
<input type="text" class="form-control" name="cliente_rua" id="rua" placeholder="rua *" required x-moz-errormessage="campo obrigatório" />
</label>
</li>
<li class="col-sm-6">
<label>
<input type="text" class="form-control" name="cliente_complemento" id="complemento" placeholder="complemento *" />
</label>
</li>
</ul>
<div class="col-sm-12 text-center">
<input type="submit" id="bt-confirmar" class="btn btn-default " value="CONFIRMAR" name="confirmar" />
</div>
</form>
connectpedido.php
<?php
include_once("scripts/config.php");
include_once("scripts/funcoes.php");
?>
<?php
$objConn = new objConexao();
$conn = $objConn->fcnConn();
$nome = $_POST['cliente_nome'];
$email = $_POST['cliente_email'];
$telefone = $_POST['cliente_telefone'];
$bairro = $_POST['cliente_bairro'];
$rua = $_POST['cliente_rua'];
$complemento = $_POST['cliente_complemento'];
$sql = "INSERT INTO cliente(cliente_nome,cliente_email,cliente_telefone,cliente_bairro,cliente_rua,cliente_complemento) VALUES ";
$sql .= "('$nome', '$email', '$telefone','$bairro','$rua','$complemento')";
echo $sql;
mysql_query($sql,$conn) or die(mysql_error());
mysql_close($conn);
echo "Cliente cadastrado com sucesso!";
?>
When I press the button to confirm it redirects me and fires the confirmation echo, I would like it to fire the message inside a modal,without displaying the bank values as I could do it?
To open the modal on the same page. you will need to make an asynchronous request (AJAX) for your PHP and if it returns an HTTP 200 response, you display the modal. The Bootstrap already has modal support if you want to use. You have knowledge about AJAX?
– Woss
You are confused, first you say return a modal "Your order has been registered" and then ...... redirect and fire the confirmation echo, I would like to!";
– user60252
To clarify, this modal would be on which page? Ordering.php clients or connectpedido.php ??
– user60252
Leo, the modal would fire inside Pedidosclients.php, I have little knowledge in AJAX, I should put the connection class inside the pagian that contains the form?
– Harakin Cheech
Just copy the form and replace it on your page. The <div id='myModal' part goes down at the bottom of the form page (Requested.php clients). On the page connectpedido.php just remove echo "Client successfully registered!";
– user60252