codeigniter validation error with field "required" - php

i have a problem with the validation form. It does not work if i put "required", example:
controller:
public function updateBenefit(){
$result = array();
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->form_validation->set_rules('beneficio', 'Nombre del Beneficio', 'required|alpha');
$this->form_validation->set_rules('info', 'Info', 'alpha');
$this->form_validation->set_rules('descrip', 'Descripción', 'alpha');
$this->form_validation->set_rules('orden', 'Orden', 'integer');
// $this->form_validation->set_rules('fecha', 'Fecha', 'date_valid');
$this->form_validation->set_message('required', 'El campo %s es requerido');
if ($this->form_validation->run() == TRUE){
if (isset($_POST['id'])){
$idb = $_POST['id'];
$benefit = BeneficiosManager::getInstance()->getHome($idb);
$result['message'] = "Se ha modificado el Beneficio con éxito";
} else{
$benefit = BeneficiosManager::getInstance()->create();
$result['message'] = "Se ha cargado el Beneficio con éxito";
}
$benefit->nombre = ucfirst(strtolower($_POST['beneficio']));
$benefit->content = ucfirst(strtolower($_POST['descrip']));
$benefit->intro = ucfirst(strtolower($_POST['info']));
$benefit->active = $_POST['optionsRadios2'];
$benefit->orden = $_POST['orden'];
// $benefit->date = $_POST['fecha'];
BeneficiosManager::getInstance()->save($benefit);
}else{
//no se validaron los datos ingresados
$result['message'] = "Error validación";
}
echo json_encode($result);
}
view:
{extends file='admin/base/base.tpl'}
{block name='content'}
<h3>Cargar Beneficio </h3>
</br>
<form action="{site_url()}admin/updateBenefit" class="form-horizontal" method="post" id="" enctype="multipart/form-data">
<div class="control-group">
<label class="control-label">Beneficio</label>
<div class="controls">
<input type="text" name="beneficio" value="" class="m-wrap medium" />
<span class="help-inline">Nombre del Beneficio</span>
</div>
</div>
<div class="control-group">
<label class="control-label">Info</label>
<div class="controls">
<textarea name="info" class="medium m-wrap" rows="3"></textarea>
<span class="help-inline">Información Clave</span>
</div>
</div>
<div class="control-group">
<label class="control-label">Descripción</label>
<div class="controls">
<textarea name="descrip" class="large m-wrap" rows="3"></textarea>
<span class="help-inline">Descripción del Beneficio</span>
</div>
</div>
<div class="control-group">
<label class="control-label">Activo</label>
<div class="controls">
<label class="radio line">
<input type="radio" name="optionsRadios2" value="1"/>Si</input>
</label>
<label class="radio line">
<input type="radio" name="optionsRadios2" value="0"/>No</input>
</label>
<span class="help-inline">Ofrecer Beneficio</span>
</div>
</div>
<div class="control-group">
<label class="control-label">Orden</label>
<div class="controls">
<input type="text" name="orden" value="" class="m-wrap small" />
<span class="help-inline">Prioridad del Beneficio</span>
</div>
</div>
<div class="control-group">
<label class="control-label">Fecha</label>
<div class="controls">
<input type="text" name="fecha" value="{$smarty.now|date_format}" class="m-wrap medium" />
<span class="help-inline"></span>
</div>
</div>
<div class="form-actions">
<button type="submit" class="btn blue"><i class="icon-ok"></i> Guardar</button>
<button type="button" class="btn">Cancelar</button>
</div>
</form>
{/block}
what might the problem be?
if i remove the "required" field, the form validates... but if i put it, it doesn't... i don't know what else to try, can't understand why this is happening
the code is working now, thanks to #Jonathan that corrected me, and i was also making an imput mistake when i was trying this method. I was trying to put two words in the same field (i.e: bon vivir); so the correct input would be: bonvivir.

I'm not sure you are using "title" as the name of your real title input element. Because I found you use this code to assign your title.
$benefit->title = ucfirst(strtolower(trim($_POST['beneficio'])));
So you may want to try to use
$this->form_validation->set_rules('beneficio', 'Nombre del Beneficio', 'required|alpha');
instead.
I am not sure I had the right guess. Just give it a go. Hope this helps.

Related

Too few arguments, 0 passed

I'm currently in an intership for a restaurant. I'm coding a website for them and I'm starting the CRUD on it.
The problem is that no data is passed to the controller, and so it doesn't update the drink.
Hope someone can help me.
I use a form to update a drink, here it is.
<div class="col-lg-6 order-lg-2">
<div class="p-5">
<p>Veuillez renseigner tous les champs !</p>
<p>Si un champ ne change pas, copier-coller ce champ depuis le tableau juste au-dessus.</p>
<form action="<?php base_url().'index.php/boissons/resp_modif_boisson/'.$son['id_boisson'] ?>" method="post">
<div class="form-group">
<label for="nom">Nom :</label>
<input type="text" class="form-control" id="nom" name="nom" maxlength="60" required>
</div>
<div class="form-group">
<label for="desc">Descriptif :</label>
<input type="text" class="form-control" id="desc" name="desc" maxlength="500" required>
</div>
<div class="form-group">
<label for="prix">Prix :</label>
<details>Si prix décimal, utilisez le "." ! (exemple : 1.99)</details>
<br>
<input type="number" class="form-control" id="prix" name="prix" min="0" step="0.01" value="0.00" required>
</div>
<button type="submit" class="btn btn-warning">Modifier</button>
</form>
</div>
</div>
And here is the controller.
public function resp_modif_boisson($num){
$this->load->helper('form');
$this->load->library('form_validation');
if($this->session->statut=="R"){
$this->form_validation->set_rules('nom', 'nom', 'required');
$this->form_validation->set_rules('desc', 'desc', 'required');
$this->form_validation->set_rules('prix', 'prix', 'required');
$nom = htmlspecialchars(addslashes($this->input->post('nom')));
$desc = htmlspecialchars(addslashes($this->input->post('desc')));
$prix = htmlspecialchars(addslashes($this->input->post('prix')));
var_dump($nom);
var_dump($desc);
var_dump($prix);
echo "test";
if ($this->form_validation->run() == FALSE){
$data['boi'] = $this->db_model->get_boisson($num);
echo "false";
$this->load->view('templates/haut_administrateur.php');
$this->load->view('resp_modif_boisson',$data);
$this->load->view('templates/bas');
}else{
$this->db_model->modif_boisson($num, $nom, $desc, $prix);
$data['boi'] = $this->db_model->get_boisson($num);
echo "true";
$this->load->view('templates/haut_administrateur.php');
$this->load->view('resp_modif_boisson',$data);
$this->load->view('templates/bas.php');
}
}else{
$data['boi'] = $this->db_model->get_all_boissons();
$this->load->view('templates/haut_accueil.php');
$this->load->view('boissons_afficher',$data);
$this->load->view('templates/bas.php');
}
}

Add to an array the content generated by a foreach

i display with a foreach the content of a user_meta in wordpress. It displays input taht fills with the values (so they can be changed). I want to be able to store each content in a new array (so i can update the user_meta next.
So here is the main code :
<?php
function edit_profile_form() {
$current_user_id = get_current_user_id();
$data = get_user_meta ($current_user_id);
if (isset($_POST['button2'])) {
delete_user_meta($current_user_id, 'experiences');
}
if(isset($_POST['button1'])) {
save_extra_profile_fields($current_user_id);
};
$experiences = get_user_meta($current_user_id, 'experiences', true);
?>
<div class="container_form">
<form method="POST">
<h3>Vos expériences</h3>
<div class="experiences_container">
<?php
if (!empty($experiences)) {
$index=0;
foreach ($experiences as $key) {
$index++;
echo($index);
echo($key);
?>
<div class="past_experience">
<div class="experience_header">
<div>
<label for="team">Nom de l'équipe</label>
<input class="team" name="team" value="<?= $key['new_experience_team'];?>"/>
</div>
<div>
<label for="role">Rôle dans l'équipe</label>
<input class="role" name="role" value="<?= $key['new_experience_role'];?>"/>
</div>
</div>
<div class="experience_textarea">
<label for="description">Description du rôle</label>
<textarea class="description" name="description"><?= $key['new_experience_description']; ?></textarea>
<label for="palmares">Palmarés avec l'équipe</label>
<textarea class="palmares" name="palmares"><?= $key['new_experience_palmares']; ?></textarea>
</div>
</div>
<?php
}
} else {
?>
<div><p>Vous n'avez encore rentré aucune expérience</p></div>
<?php
}?>
</div>
<div class="add_container">
<div id="dropdown">
<i class="fas fa-plus-square" style="margin-right: 5px;"></i>
<p id="show" onClick="dropdown()" >Ajouter une expérience</p>
</div>
<div id="experience" style="display:none;">
<label for="new_experience_team">Nom de l'équipe</label>
<input type="text" name="experiences[new_experience_team]" id="experience_team">
<label for="new_experience_role">Rôle dans l'équipe</label>
<input type="text" name="experiences[new_experience_role]" id="experience_role">
<label for="new_experience_description">Description du poste</label>
<textarea type="text" name="experiences[new_experience_description]" id="experience_description"></textarea>
<label for="new_experience_palmares">Palmarés</label>
<textarea type="text" name="experiences[new_experience_palmares]" id="experience_palmares"></textarea>
</div>
</div>
<div id="button_container">
<input type="submit" name="button1" value="Sauvegarder" id='save'/>
<input type="submit" name="button2" value="Annuler"/>
</div>
</form>
</div>
The function's one :
<?php
function save_extra_profile_fields( $user_id ) {
if (!empty($_POST['experiences'])) {
$savedexperience = get_user_meta($user_id, 'experiences', true);
if (!empty($savedexperience) && is_array($savedexperience )) {
$experiences = $savedexperience;
}
$experiences[] = $_POST['experiences'];
update_usermeta($user_id, 'experiences', $experiences);
}
}
So i want to be able to stock in a array each group of team, role, description and palmares.
I don't know if it's clear at all :/
Thanks all

Trying to insert data from a drop-down list as a foreign key in another table. Data not inserted

I been trying to figure out where my mistake is without success. I get no reported errors. I want to insert data into the supplier table from a PHP form. id_drugstore is a foreign key into the supplier table and can be chosen form a drop-down list (drop-down is working perfect). Another date is filled in by the user, except id_supplier.
<?
error_reporting(-1);
$conn = mysqli_connect("localhost", "root", "", "retete");
if(mysqli_connect_errno())
{
echo "Nu ma pot conecta la baza de date medical:" .mysqli_connect_error();
}
if(isset($_POST['submit']){
$id_drugstore=$_POST['id_drugstore'];
$name_suplier=$_POST['name_suplier'];
$country_supplier=$_POST['county_supplier'];
$county_supplier=$_POST['county_supplier'];
$town_supplier=$_POST['town_supplier'];
$street_supplier=$_POST['street_supplier'];
$bank_suplier=$_POST['bank_suplier'];
$no_cont_Bank=$_POST['$no_cont_Bank'];
$qry=mysqli_query("INSERT INTO supplier `VALUES('sss','%$id_drugstore%',$_POST['name_suplier']','$_POST['county_supplier']','$_POST['county_supplier']','$_POST['town_supplier']','$_POST['street_supplier']','$_POST['bank_suplier']','$_POST['$no_cont_Bank']";`
$inserted=($qry,$conn);
if($inserted){
echo "Datele au fost inserate cu suucess";
}else{
echo "datele nu au putut fi salvate in baza de date".mysqli_error($conn);
}
}
mysqli_close($conn);
}
?>
<body>
<div class="jumbotron">
<div class="container">
<h4 class="display-5">Adaugare Furnizori in baza de date</h4>
<p class="lead">Completati formularul de mai jos</p>
</div>
</div>
<form action="AdaugareFurnizori.php" method="POST">
<div class="form-row">
<div class="col-md-2 mb-3">
<label for="validationServer01">Farmacie</label>
<select name="name_drugstore">
<option>Selecteaza farmacie</option>
<?php
$conn = mysqli_connect("localhost", "root", "", "retete");
if(mysqli_connect_errno()){
echo "Nu ma pot conecta la baza de date medical:".mysqli_connect_error();
}
$q=mysqli_query($conn,"SELECT * FROM drugstore")or die(mysqli_error());
$c=mysqli_num_rows($q);
if($c==0){
echo 'Nu exista farmacie in baza de date';
}else{
while($row=mysqli_fetch_array($q)){
$id_drugstore=$row['id_drugstore'];
$name_drugstore=$row['name_drugstore'];
echo "<option value='$id_drugstore'>$id_drugstore/$name_drugstore<option>
}
}
mysqli_close($conn);
?>
</select>
</div>
</div>
<div class="form-row">
<div class="col-md-4 mb-3">
<label for="validationServer01">Denumire Furnizori</label>
<input type="text" name="name_suplier" class="form-control is-valid" id = "validationServer01" placeholder="Denumire Furnizor" required>
</div>
</div>
<div class="form-row">
<div class="col-md-2 mb-3">
<label for="validationServer02">Tara</label>
<input type="text" name="country_supplier" class="form-control is-valid" id="validationServer02" placeholder="Tara" required>
<div class="invalid-feedback">
Va rugam sa introduceti tara.
</div>
</div>
<div class="col-md-2 mb-3">
<label for="validationServer03">Judet</label>
<input type="text" name="county_supplier" class="form-control is-valid" id="validationServer03" placeholder="Judet" required>
<div class="invalid-feedback">
Va rugam sa introduceti judetul.
</div>
</div>
<div class="col-md-2 mb-3">
<label for="validationServer04">Oras</label>
<input type="text" name="town_supplier"class="form-control is-valid" id="validationServer04" placeholder="Oras" required>
<div class="invalid-feedback">
Va rugam sa introduceti orasul.
</div>
</div>
<div class="col-md-2 mb-3">
<label for="validationServer05">Strada si numar</label>
<input type="text" name="street_supplier" class="form-control is-valid" id="validationServer05" placeholder="Strada" required>
<div class="invalid-feedback">
Va rugam sa introduceti strada.
</div>
</div>
<div class="col-md-2 mb-3">
<label for="validationServer04">Banca</label>
<input type="text" name="bank_suplier"class="form-control is-valid" id="validationServer04" placeholder="Denumire Banca" required>
<div class="invalid-feedback">
Va rugam sa introduceti banca.
</div>
</div>
<div class="col-md-2 mb-3">
<label for="validationServer05">Cont</label>
<input type="text" name="no_cont_Bank" class="form-control is-valid" id="validationServer05" placeholder="Numar Cont" required>
<div class="invalid-feedback">
Va rugam sa introduceti numarul contului.
</div>
</div>
<div class="submit">
<button class="btn btn-primary" type="submit">Submit form</button>
</div>
</div>
</form>
</body>
</html>
That query looks strange:
$qry=mysqli_query("INSERT INTO supplier `VALUES('sss','%$id_drugstore%',$_POST['name_suplier']','$_POST['county_supplier']','$_POST['county_supplier']','$_POST['town_supplier']','$_POST['street_supplier']','$_POST['bank_suplier']','$_POST['$no_cont_Bank']";`
Remove the backticks `
Missing an opening ' before $_POST['name_suplier']'
All of your $_POST variables in that string will never get replaced, put them in curly brackts: {$_POST['name_suplier']}
Make sure you have no typos in there name_suplier vs. town_supplier
Missing a closing bracket at the end of the query AND as a closing bracket for mysql_query()
Side note: Shouldn't there be a list of fields in that INSERT too?
your code should be.
If your supplier table have all this field which you are going to insert then this will works fine but if u skip any of the field then mysqli_query does not work
$qry="INSERT INTO supplier `VALUES('sss','%$id_drugstore%',$_POST['name_suplier']','$_POST['county_supplier']','$_POST['county_supplier']','$_POST['town_supplier']','$_POST['street_supplier']','$_POST['bank_suplier']','$_POST['$no_cont_Bank']')";
$inserted=mysqli_query($qry,$conn);

Codeigniter action form not working

I try to understand why my form action is not taking me to the controller...I press the update button on my modal, which should update info on modal to the database...and when I press it, nothing happens, no error , no message, it just close the modal and that's it. HELP PLS !!!. Here is my code:
FORM
<div id="modal1" class="modal modal-fixed-footer">
<div class="modal-content">
<h3 class="center-align">Actualizar registro</h3>
<div class="row">
<form class="col s12" id="update_form" enctype="multipart/form-data" method="post" action ="<?= base_url()?>admin/update_politic">
<div class="row">
<div class="input-field col s6">
<input id="update_name" type="text" name="name" class="validate">
<label for="first_name">Nombre</label>
</div>
<div class="input-field col s6">
<input id="update_last_name" name="lastname" type="text" class="validate">
<label for="last_name">Apellido</label>
</div>
</div>
<div class="row">
<div class="input-field col s6">
<input id="update_side" type="text" name="side" class="validate">
<label for="partido">Partido</label>
</div>
<div class="input-field col s6">
<input id="update_charge" type="text" name="charge" class="validate">
<label for="cargo">Cargo</label>
</div>
</div>
<div class="row">
<div class="input-field col s6">
<div class="file-field input-field no-margin-top">
<div class="btn light-blue darken-4">
<span>Animación/Imagen</span>
<input type="file" name="animation_file">
</div>
<div class="file-path-wrapper">
<input class="file-path validate" id="animation" name="animation" type="text">
</div>
</div>
</div>
<div class="input-field col s6">
<select id="update_section" name="section" autocomplete="off">
<option value="" disabled selected>Seleccione una opción</option>
<option value="1">Presidencia</option>
<option value="2">Senadores</option>
<option value="3">Diputados</option>
</select>
<label>Sección</label>
</div>
</div>
<input type="hidden" name="update_politic_hide" id="update_politic_hdn" value="">
<div class="row">
<button class="btn waves-effect waves-light light-blue darken-4" id="submit_update" type="submit" name="action">Actualizar</button>
</div>
</form>
</div>
</div>
CONTROLLER
public function update_politic(){
echo "entreeeeeeee";
if (empty($_FILES['animation_file']['name']))//Compruebo si el array $_files no tiene ningun valor en su elemento name
{
//El metodo obtenerImagen me retorna los valores de dicho id
$data = $this->politic->get_file_name($this->input->post('update_politic_hide'));
$imagen = $data->POLITIC_FILE;//recupero el nombre de la imagen
}
else{
//en caso exista algun valor se procede a subir
$this->load->library("upload");
$config['upload_path'] = "./public/uploads/";
$config['allowed_types'] = "*";
$config['max_size'] = "500000";
$config['max_width'] = "2000";
$config['max_height'] = "2000";
if (!$this->upload->do_upload("animation")) {
$data['uploadError'] = $this->upload->display_errors();
echo $this->upload->display_errors();
}
else {
$file_info = $this->upload->data();
$params["name"] = $this->input->post("name");
$params["lastname"] = $this->input->post("lastname");
$params["side"] = $this->input->post("side");
$params["charge"] = $this->input->post("charge");
$params["animation"] = $file_info['file_name'];
$params["section"] = $this->input->post("section");
if ($params["section"]=="Presidencia") {
$params["section"]=1;
}
if ($params["section"]=="Senadores") {
$params["section"]=2;
}
if ($params["section"]=="Diputados") {
$params["section"]=3;
}
$this->load->model("politic");
$this->politic->update($params);
}
}
}
You have used base_url()?>admin/update_politic for submitting your form. But you have not mentioned about that controller. If you have admin controller then it will be ok. Otherwise, this is the reason for this submission.
Try This
<?php echo form_open(base_url() . 'admin/update_politic' , array('class' => 'form-horizontal form-groups-bordered validate', 'enctype' => 'multipart/form-data'));?>
Instead of button use <input type = "submit" value ="Submit" class="your class name here">

Get checkbox value on pgp email form

I got this code working (i´m not programmer, but I really need this), it´s sending email with all values, but the checkbox values are blank on the email, even when they´re checked... any help please?
important: serv-opcao(x) and doc-opcao(x) are the ckeckboxes names.
<?php
$nome = $_POST['nome'];
$email = $_POST['email'];
$telefone = $_POST['telefone'];
$serv_opcao1 = $_POST[serv-opcao1];
$serv_opcao2 = $_POST[serv-opcao2];
$serv_opcao3 = $_POST[serv-opcao3];
$serv_opcao4 = $_POST[serv-opcao4];
$serv_opcao5 = $_POST[serv-opcao5];
$serv_opcao6 = $_POST[serv-opcao6];
$serv_opcao7 = $_POST[serv-opcao7];
$outros = $_POST[outros];
$slogan = $_POST[slogan];
$url = $_POST[url];
$doc_opcao1 = $_POST[doc-opcao1];
$doc_opcao2 = $_POST[doc-opcao2];
$doc_opcao3 = $_POST[doc-opcao3];
$doc_opcao4 = $_POST[doc-opcao4];
$doc_opcao5 = $_POST[doc-opcao5];
$doc_opcao6 = $_POST[doc-opcao6];
$outros = $_POST[outros2];
$mensagem1 = $_POST[mensagem1];
$mensagem2 = $_POST[mensagem2];
$mensagem3 = $_POST[mensagem3];
$emaildestino = 'lucasvallimdacosta#me.com';
$email_from='lucasvallimdacosta#me.com';
$mensagem = $_POST['mensagem'];
$assunto = $_POST['assunto'];
$titulo = 'Site Lucas Vallim - Nova Mensagem';
$juntando = '<p>Esta mensagem foi enviada pelo site</p><br/>
<p><b>Nome:</b> '.$nome.'</p>
<p><b>Email:</b> '.$email.' </p>
<p><b>Telefone:</b> '.$telefone.'</p>
<p><b>Serviços desejados:</b></p>
<p> '.$serv_opcao1.' '.$serv_opcao2.' '.$serv_opcao3.' '.$serv_opcao4.' '.$serv_opcao5.' '.$serv_opcao6.' '.$serv_opcao7.' </p>
<p><b>Outros (se houver):</b> '.$outros.'</p>
<p><b>Slogan:</b>'.$slogan.'</p>
<p><b>Url:</b>'.$url.'</p>
<p><b>Documentação disponível:</b></p>
<p> '.$doc_opcao1.' '.$doc_opcao2.' '.$doc_opcao3.' '.$doc_opcao4.' '.$doc_opcao5.' '.$doc_opcao6.'</p>
<p><b>Outros (se houver):</b> '.$outros2.'</p>
<p><b>Existe hoje algum problema de comunicação com o público-alvo?</b></p>
<p>'.$mensagem1.'</p>
<p><b>Você pretende que o trabalho esteja pronto em quanto tempo?</b></p>
<p>'.$mensagem2.'</p>
<p><b>Descreva, com suas palavras, tudo sobre o serviço desejado</b></p>
<p>'.$mensagem3.'</p>
<hr>';
$headers = 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n";
$headers .= "From: $email_from " . "\n";
$envio = mail($emaildestino, $titulo, $juntando, $headers, "-r".$email_from);
if($envio)
header('Location:http://www.google.com');
else
echo "A mensagem não pode ser enviada";
?>
here´s the HTML form:
<form method="POST" name="contactform" id="meu_form" class="form-horizontal" action="design.php">
<br>
<fieldset>
<legend>Dados Pessoais</legend>
<div class="control-group">
<label class="control-label" for="inputNome">Nome</label>
<div class="controls">
<input type="text" name="nome" id="nome" id="inputNome" placeholder="">
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputEmail">Email</label>
<div class="controls">
<input type="text" name="email" id="email" id="inputEmail" placeholder="">
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputTelefone">Telefone</label>
<div class="controls">
<input type="text" name="telefone" id="telefone" id="inputTelefone" placeholder="">
</div>
</div>
</fieldset>
<br>
<fieldset id="fundo_safari">
<legend>Formulário para criação de <b>Design Gráfico</b></legend>
<div class="control-group">
<label class="control-label" for="inputPassword">Qual o serviço de interesse?<br>
</label>
<div class="controls">
<label class="checkbox">
<input type="checkbox" name="serv-opcao1" id="serv-opcao1" value="Cartão de Visitas">
Cartão de Visitas
</label>
<label class="checkbox">
<input type="checkbox" name="serv-opcao2" id="serv-opcao2" value="Banner">
Banner
</label>
<label class="checkbox">
<input type="checkbox" name="serv-opcao3" id="serv-opcao3" value="Folheto">
Folheto
</label>
<label class="checkbox">
<input type="checkbox" name="serv-opcao4" id="serv-opcao4" value="Papel Timbrado">
Papel Timbrado
</label>
<label class="checkbox">
<input type="checkbox" name="serv-opcao5" id="serv-opcao5" value="Pasta Institucional">
Pasta Institucional
</label>
<label class="checkbox">
<input type="checkbox" name="serv-opcao6" id="serv-opcao6" value="Assinatura de Email">
Assinatura de e-mail
</label>
<label class="checkbox">
<input type="checkbox" name="serv-opcao7" id="serv-opcao7" value="Outros">
Outros
</label>
<input type="text" name="outros" id="outros" id="inputOutros" placeholder="Especifique">
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputEndereço">Possui um slogan?<span id="complemento_label"> (se houver, indique qual).</span></label>
<div class="controls">
<input type="text" name="slogan" id="slogan" placeholder="">
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputEndereço">Endereço do website atual<span id="complemento_label"> (se houver).</span></label>
<div class="controls">
<div class="input-prepend">
<span class="add-on">http://</span>
<input type="text" id="url" name="url" id="inputNome" placeholder="">
</div>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Qual a documentação disponível?<br>
</label>
<div class="controls">
<label class="checkbox">
<input type="checkbox" name="doc-opcao1" id="doc-opcao1" value="Logo Tipo">
Logotipo
</label>
<label class="checkbox">
<input type="checkbox" name="doc-opcao2" id="doc-opcao2" value="Impresso Institucional">
Impresso Institucional
</label>
<label class="checkbox">
<input type="checkbox" name="doc-opcao3" id="doc-opcao3" value="Manual">
Manual
</label>
<label class="checkbox">
<input type="checkbox" name="doc-opcao4" id="doc-opcao5" value="Fotos">
Fotos
</label>
<label class="checkbox">
<input type="checkbox" name="doc-opcao5" id="doc-opcao5" value="Videos">
Videos
</label>
<label class="checkbox">
<input type="checkbox" name="doc-opcao6" id="doc-opcao6" value="Outros">
Outros
</label>
<input type="text" name="outros2" id="outros2" id="inputOutros" placeholder="Especifique">
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Existe hoje algum problema de comunicação com o público-alvo?
</label>
<div class="controls">
<textarea rows="4" name="mensagem1" id="mensagem1"></textarea>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Você pretende que o trabalho esteja pronto em quanto tempo? <span id="complemento_label">(Prazo máximo)</span>
</label>
<div class="controls">
<textarea rows="4" name="mensagem2" id="mensagem2"></textarea>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Descreva, com suas palavras, tudo sobre o serviço desejado <span id="complemento_label">(objetivo, funcionalidade, exigências, etc.)</span>
</label>
<div class="controls">
<textarea rows="4" name="mensagem3" id="mensagem3"></textarea>
</div>
</div>
<div class="control-group">
<div class="controls">
<button type="submit" class="btn btn-primary">Enviar</button>
</div>
</div>
</fieldset>
</form>
Hint by simple code highlighting:
$telefone = $_POST['telefone'];
$serv_opcao1 = $_POST[serv-opcao1];
Spot the difference between working and not-working. Without quotes, PHP sees constant serv minus constant opaco1. Since both are undefined, they are treated as strings. And those strings doe not have any numerical value, so result of 0 - 0 is 0 and there is no $_POST[0]; If you have error reporting / logging on your server, you would see many notices about undefined constants / indexes. Error reporting and logs are first things to refer to when something does not work.
Moreover, php will not allow you to use some characters in request variables, automatically converting them to underscores, so try $_POST['serv_opcao1']; This should not be true for dashes, only spaces and dots.

Categories