Sorry for asking something that seems to have been asked many times, but is because I'd not found anything so... simple as my case, so I'm not so sure about that path to follow.
The thing is, I have a form, in the page "estimate.php" with most of its input types as Text, and some checkboxes. Its action is set to "insert.php", where is the code that sends the e-mail, and sends the data to the database, and on the end of it, an alert and a redirection to the form page.
When I fill the form without checking anything on the checkboxes, everything works just fine, the database columns are filled perfectly, and the e-mail is correctly sent, the fields that were supposed to receive the checkboxes values are blank, as it was supposed to be, since I've not filled them. But once I try to use the checkboxes, when I hit Submit, I get a empty page, and the address freezes on insert.php. I'm not sure what is happening, but since I haven't worked with Checkbox to SQL before, and I'm pretty newbie on coding, I think it has something to do with the way I'm trying to process the data from the checkboxes to send it to the db. I understood that, setting values to each checkbox, it would post them as text.
Here are the codes (the most important parts of if, to try to summarize. [...] are in place of parts I took away, to make it more simple for you to help me.)
- FORM:
<form id="contact-form" action="../painel/insert.php" method="POST">
//[...]
<div style="margin-top: 20px;">
<p style="margin-bottom: 0;">Quantidade de pares por numeração</p>
<br />
<div class="table-responsive">
<table class="table table-bordered">
<tr>SANDÁLIAS INFANTIS</tr>
<thead>
<tr>
<th class="text-center">Numeração</th>
<th class="text-center">Quantidade</th>
<th class="text-center">Alça</th>
</tr>
</thead>
<tbody>
<tr>
<td>25/26</td>
<td><input type="text" name="i2526_quant"></td>
<td style="text-align: left;">
<input type="checkbox" name="i2526_a" value="Slim"> Slim<br>
<input type="checkbox" name="i2526_a" value="Tradicional"> Tradicional
</td>
</tr>
<tr>
<td>27/28</td>
<td><input type="text" name="i2728_quant"></td>
<td style="text-align: left;">
<input type="checkbox" name="i2728_a" value="Slim"> Slim<br>
<input type="checkbox" name="i2728_a" value="Tradicional"> Tradicional
</td>
</tr>
<tr>
<td>29/30</td>
<td><input type="text" name="i2930_quant"></td>
<td style="text-align: left;">
<input type="checkbox" name="i2930_a" value="Slim"> Slim<br>
<input type="checkbox" name="i2930_a" value="Tradicional"> Tradicional
</td>
</tr>
<tr>
<td>31/32</td>
<td><input type="text" name="i3132_quant"></td>
<td style="text-align: left;">
<input type="checkbox" name="i3132_a" value="Slim"> Slim<br>
<input type="checkbox" name="i3132_a" value="Tradicional"> Tradicional
</td>
</tr>
</tbody>
</table>
</div>
//[...]
<input type="submit" class="submit no-margin-bottom" value="Enviar" style="font-size:20 px; padding: 10px; border: 3px solid #555555;"/>
</form>
- THE CODE, on Insert.php:
<?php
include "conexao.php";
//[...]
$i2526_quant = $_POST['i2526_quant'];
$i2526_a = $_POST['i2526_a'];
$i2728_quant = $_POST['i2728_quant'];
$i2728_a = $_POST['i2728_a'];
$i2930_quant = $_POST['i2930_quant'];
$i2930_a = $_POST['i2930_a'];
$i3132_quant = $_POST['i3132_quant'];
$i3132_a = $_POST['i3132_a'];
//[...]
$inserir = "INSERT INTO orcamento VALUES([...],'$i2526_quant','$i2526_a','$i2728_quant','$i2728_a','$i2930_quant','$i2930_a','$i3132_quant','$i3132_a',[...])";
//[...](here is the part of the code that sends the e-mail. As I said, everything is working fine, except for the checkboxes (actually, I took away the part from the code that would send the checkbox values to the e-mail and tested it again, and it didn't work. Since the code is pretty long, I decided not to post it (if you need to, I will).
$enviado = $mail->Send();
if ($enviado) {
//$envia = mail($recipient, $subject, $message, $headers);
echo '<script>alert("Obrigado! Orcamento enviado com sucesso, responderemos o mais breve possível.");location="../estimate.php";</script>';
}else{
echo '<script>alert("Erro ao enviar orcamento.");location="../estimate.php";</script>';
} }
?>
-- Thank you very much in advance. I'm sorry for the poor english, and for being such a newbie, as I'm pretty sure this is a simple thing to solve, but hey, here I am trying to learn from the bests (:
Aucun commentaire:
Enregistrer un commentaire