Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Olá Boa noite..
Estou com dificuldade em pegar o valor de checkbox do formulário.
Sempre retorna o seguinte erro..
Warning: Invalid argument supplied for foreach() in C:\wamp\www\whb\site\_app\_class\class.trabalhe-conosco.php on line 106
queria entender pq dá sempre erro no foreach(), já peguei vários exemplos da internet, mas não tive sucesso... alguém pode me auxiliar..
Segue o html do formulário
<form method="post" enctype="multipart/form-data" id="form1">
<table width="900" border="0">
<tr>
<td><table width="450" height="296" border="0" style="position: relative; top:0; left:0;">
<tr>
<td height="42"><div class="campo"><input type="text" value="<?=$trabalhe->traducao('trabalhe_cpf'); ?>" name="cpf" rel="<?=$trabalhe->traducao('trabalhe_cpf'); ?>" style="width:404px; height:20px;"/></div></td>
</tr>
<tr>
<td height="42"><div class="campo"><input type="text" value="<?=$trabalhe->traducao('trabalhe_nome'); ?>" name="nome" rel="<?=$trabalhe->traducao('trabalhe_nome'); ?>" style="width:404px; height:20px;"/></div></td>
</tr>
<tr>
<td height="34" ><div class="campo"><input type="text" value="<?=$trabalhe->traducao('trabalhe_telefone'); ?>" id="telefone" name="telefone" rel="<?=$trabalhe->traducao('trabalhe_telefone'); ?>" style="width:404px; height:20px;"/></div></td>
</tr>
<tr>
<td height="61"><div class="campo"><input type="text" id="email" value="<?=$trabalhe->traducao('trabalhe_email'); ?>" name="email" rel="<?=$trabalhe->traducao('trabalhe_email'); ?>" style="width:404px; height:20px;"/></div></td>
</tr>
<tr>
<td height="61"><div class="campo"><input type="text" id="cidade" value="<?=$trabalhe->traducao('trabalhe_cidade'); ?>" name="cidade" rel="<?=$trabalhe->traducao('trabalhe_cidade'); ?>" style="width:404px; height:20px;"/></div></td>
</tr>
<tr>
<td height="61"><div class="campo"><input type="text" id="estado" value="<?=$trabalhe->traducao('trabalhe_estado'); ?>" name="estado" rel="<?=$trabalhe->traducao('trabalhe_estado'); ?>" style="width:404px; height:20px;"/></div></td>
</tr>
<tr>
<td height="61">
<div class="campo-nivel">
Nível
<br/><br/>
<input type="checkbox" name="nivel[]" value="Estágio"> Estágio
<input type="checkbox" name="nivel[]" value="Operacional"> Operacional
<input type="checkbox" name="nivel[]" value="Analista"> Analista<br/><br/>
<input type="checkbox" name="nivel[]" value="Supervisão"> Supervisão
<input type="checkbox" name="nivel[]" value="Gerência/Diretoria"> Gerência/Diretoria
</div>
</td>
</tr>
<tr>
<td height="61"><div class="campo"><input type="text" id="salario" value="<?=$trabalhe->traducao('trabalhe_salario'); ?>" name="salario" rel="<?=$trabalhe->traducao('trabalhe_salario'); ?>" style="width:404px; height:20px;"/></div></td>
</tr>
<tr>
<td height="61"><div class="campo"><input type="text" id="pretensao" value="<?=$trabalhe->traducao('trabalhe_pretensao'); ?>" name="pretensao" rel="<?=$trabalhe->traducao('trabalhe_pretensao'); ?>" style="width:404px; height:20px;"/></div></td>
</tr>
<tr>
<td height="34" ><div class="campo"><span><?=$trabalhe->traducao('trabalhe_curriculo'); ?></span> <input type="file" class="file" name="arquivo" style="height:20px;" /></div><hr/></td>
</tr>
<tr>
<td>
<div style="width:192px;height:35px; float:right; right:29px;position:relative;">
<div style="background:url(<?=URL; ?>/_app/_img/contato-botao_enviar.jpg) no-repeat; width:192px; height:35px;position:absolute; left:0; top:0;"></div>
<input type="submit" name="send" id="send" value="<?=$trabalhe->traducao('trabalhe_enviar'); ?>" style="background:none;width:190px; text-align:center; color:#fff; width:185px; padding:0; margin:0; height:30px; font:bold 16px/35px Arial;position:absolute; left:0; top:0;"/>
</div>
</td>
</tr>
</table>
</td>
<td width="50%" valign="top">
<div class="oportunidades">
<h1><?=$trabalhe->traducao('oportunidades'); ?></h1>
<div class="lista">
<? for($i=0; $i<count($trabalhe->vagas); $i++) { ?>
<h2><?=$trabalhe->vagas[$i]['titulo']; ?></h2>
<h3><?=$trabalhe->vagas[$i]['texto']; ?></h3>
<? } ?>
</div>
</div>
</td>
</tr>
</table>
</form>
e a função em php que envia o formulário... ele envia o formulário para o email e grava na base de dados..
function trabalhe_enviar() {
if(!empty($_POST['cpf'])){
if($file = LibFile::file_upload('arquivo', $destino='_user/', true)) {
$arquivo = '<a href="'.URL.'/_user/'.$file.'" target="_blank">Download</a>';
} else {
$arquivo = 'Não enviado.';
}
$message = '<html>
<body>
<table>
<tr><td><b>Setor:</b></td><td> '.$_POST["setor"].'</td></tr>
<tr><td><b>Nome:</b></td><td> '.$_POST["nome"].'</td></tr>
<tr><td><b>Email:</b></td><td> '.$_POST["email"].'</td></tr>
<tr><td><b>Telefone:</b></td><td>'.$_POST["telefone"].'</td></tr>
<tr><td><b>Currículo:</b></td><td>'.$arquivo.'</td></tr>
<tr><td><b>Obs:</b></td><td> '.$_POST["mensagem"].'</td></tr>
</table>
</body>
</html>';
$destQ = "SELECT * FROM ".DB_PREF."admin_formulario WHERE formulario='trabalhe_conosco' LIMIT 1";
$dest = mysql_query($destQ);
if(mysql_num_rows($dest) > 0) {
$destRow = mysql_fetch_assoc($dest);
}
@mysql_free_result($dest);
$from = $destRow['remetente'];
$to = explode(';', $destRow['destinatario']);
$headers = "MIME-Version: 1.1\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: ".$from."\r\n"; // remetente
$headers .= "Return-Path: ".$from."\r\n"; // return-path
$assunto = "WHB - envio de formulário trabalhe conosco via website";
if(@mail($to[0], $assunto, $message, $headers)) {
for($i=1; $i<count($to); $i++) {
@mail($to[$i], $assunto, $message, $headers);
}
$this->ok = true;
} else {
$this->erro = true;
}
if(!empty($_POST['nivel'])){
$nivel = $_POST['nivel'];
foreach ($nivel as $value){
echo $value. "<br/>";
}
}
$inQ = "INSERT INTO ".DB_PREF."trabalhe_formulario SET
fk_idioma='".$this->id_idioma."',
ip='".$_SERVER['REMOTE_ADDR']."',
datahora=now(),
cpf='".$_POST["cpf"]."',
nome='".$_POST["nome"]."',
email='".$_POST["email"]."',
telefone='".$_POST["telefone"]."',
cidade='".$_POST["cidade"]."',
estado='".$_POST["estado"]."',
salario='".$_POST["salario"]."',
pretensao='".$_POST["pretensao"]."',
curriculo='".$file."' ";
$in = mysql_query($inQ);
}
}
Obrigada!!
Carregando comentários...