• 0
Sign in to follow this  
Esvaldo Marcos

Como usar o foreach

Question

Olá a todos, passei mais de um mês tentando usar o foreach (acredito que é esse cara que vai resolver meu problema) e não consegui.

Tenho um formulário, e nele tem uma tabela, onde nesta tabela eu adiciono outras linhas de acordo com a minha necessidade.

O que eu não consigo fazer é enviar os campos da tabela para o email.

Alguém poderia me ajudar.

Segue o código do form e do enviar.php

 

<?php
// Template Name: Plano de Corte
/**
 *
 * Este é o modelo de página de Plano de Corte.
 * Aqui está o formulário que será enviado por email com os dados do plano de corte solicitado.
 *
 * @link http://codex.wordpress.org/Template_Hierarchy
 *
 * @package  i-max
 * @since i-max 1.0
 */

get_header(); ?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Formulário Plano de Corte</title>

    <!-- Bootstrap -->
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="http://www.norteplac.com.br/wp-content/themes/i-max/css/style-form.css">


<!-- Latest compiled and minified JavaScript -->
<script src="js/bootstrap.min.js"></script>
  <!--função adicionar campo na tabela-->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
<script type="text/javascript">
function clonarLinha() {
  var row = document.getElementById("linhaParaClonar");
  var table = document.getElementById("tabela");
  var clone = row.cloneNode(true);
  clone.id = "linhaClonada";
  table.appendChild(clone);
}
function deletarLinha(){
	var row = document.getElementById("linhaClonada");	
	while (linhaClonada.firstChild){linhaClonada.removeChild(linhaClonada.firstChild);	}}
</script>
<!--fim da função adicionar campo na tabela-->
  </head>
  <body>

<form action="http://www.norteplac.com.br/wp-content/themes/i-max/enviar.php" class="form-inline" method="post">

<!-- Form Name -->
<fieldset>
    <h1>Identificação do Cliente</h1><br />

	<div class="form-group-numero">
		<label class="col-input-nome" for="textinput"></label>
		  <div class="col-md-n">
		<input  id="textinput_numero"  name="textinput_numero" type="text" value="<?php echo rand(1,100000); ?>" class="desabilitado" readonly />
		</div>
	</div>
<!-- Text input-->
<div class="form-group-nome">
  <label class="col-input-nome" for="textinput">Nome</label>  
  <div class="col-md-4">
  <input id="textinput_nome" name="textinput_nome" type="text" required="required" placeholder="Digite o seu nome..." class="form-input-nome"> 
  </div>
</div>

<div class="form-group-email">
  <label class="col-input-email" for="textinput">E-Mail</label>  
  <div class="col-md-4">
  <input id="textinput_email" name="textinput_email" type="text" required="required" placeholder="Digite o seu e-mail..." class="form-input-email"> 
  </div>
</div>

<div class="form-group-telefone">
  <label class="col-md-4 control-label" for="textinput">Tel. (DDD)</label>  
  <div class="col-md-4">
  <input id="textinput_telefone" name="textinput_telefone" type="text" required="required" pattern="^\d{2}\d{4}\d{4}$" placeholder="XX12345678" class="form-input-telefone"> 
  </div>
</div>

<div class="form-group-projeto">
  <label class="col-md-6 control-label" for="textinput">Nome do Projeto</label>  
  <div class="col-md-4">
  <input id="textinput_projeto" name="textinput_projeto" type="text" placeholder="O que pretende fazer?" class="form-input-projeto"> 
  </div>
</div>
<div class="form-group-vendedor">
  <label class="col-md-1 control-label" for="selectbasic">Vendedor</label>
  <div class="col-md-4">
    <select id="select_vendedor" required="required" name="select_vendedor" class="form-control">
	  <option value=""></option>
          <option value="INDIFERENTE">INDIFERENTE</option>
	  <option value="ALEXANDRE">ALEXANDRE</option>
      	  <option value="CANA">CANA</option>
          <option value="GEOVÂNIA">GEOVÂNIA</option>
	  <option value="KLEBER">KLEBER</option>
	  <option value="TINICO">TINICO</option>
	  <option value="VERA">VERA</option>
	  </select>
  </div>
</div>
</fieldset>
    <h1>Material</h1><br />
<!-- Select Basic -->
<div class="form-group-cor">
  <label class="col-md-1 control-label" for="selectbasic">Cor</label>
  <div class="col-md-4">
    <select id="select_material" required="required" name="select_material" class="form-control">
	  <option value="">SELECIONE O PADRÃO DE CHAPA QUE VOCÊ PRECISA</option>
      <option value="MDF CRU">MDF CRU</option>
      <option value="MDF CRU ULTRA">MDF CRU ULTRA</option>
	  <option value="HDF BRANCO">HDF BRANCO</option>
      <option value="MDF AMANTEA TATTO">MDF AMANTEA TATTO</option>
	  <option value="MDF AZUL TX">MDF AZUL TX</option>
      <option value="MDF BARRIQUE TATTO">MDF BARRIQUE TATTO</option>
	  <option value="MDF BAUMKUCHEN TATTO">MDF BAUMKUCHEN TATTO</option>
      <option value="MDF BRANCO CANALETADO">MDF BRANCO CANALETADO 3"</option>
	  <option value="MDF BRANCO DESIGN">MDF BRANCO DESIGN</option>
      <option value="MDF BRANCO DIAMANTE">MDF BRANCO DIAMANTE</option>
	  <option value="MDF BRANCO DIAMANTE ULTRA">MDF BRANCO DIAMANTE ULTRA</option>
      <option value="MDF BRANCO LISO">MDF BRANCO LISO</option>
	  <option value="MDF BRANCO MATTE">MDF BRANCO MATTE</option>
      <option value="MDF BRANCO NEVE LACA">MDF BRANCO NEVE LACA</option>
	  <option value="MDF BRANCO TATTO">MDF BRANCO TATTO</option>
      <option value="MDF BRANCO TX">MDF BRANCO TX</option>
	  <option value="MDF BRANCO ULTRA TX">MDF BRANCO ULTRA TX</option>
      <option value="MDF CARVALHO ATENAS PORO">MDF CARVALHO ATENAS PORO</option>
	  <option value="MDF CARVALHO NICE PORO">MDF CARVALHO NICE PORO</option>
      <option value="MDF CARVALHO TREVISO DESIGN">MDF CARVALHO TREVISO DESIGN</option>
	  <option value="MDF CASTAINE TATTO">MDF CASTAINE TATTO</option>
      <option value="MDF CHIARO VEL">MDF CHIARO VEL</option>
	  <option value="MDF CINZA ARGILA TX">MDF CINZA ARGILA TX</option>
      <option value="MDF CINZA COBALTO TX">MDF CINZA COBALTO TX</option>
	  <option value="MDF CINZA CRISTAL TX">MDF CINZA CRISTAL TX</option>
      <option value="MDF DAKOTA DESIGN">MDF DAKOTA DESIGN</option>
	  <option value="MDF DAMASCO TX">MDF DAMASCO TX</option>
      <option value="MDF DOTS PLAY">MDF DOTS PLAY</option>
	  <option value="MDF FRAME PLAY">MDF FRAME PLAY</option>
      <option value="MDF FRASSINO LIS BRANCO SYNCRO">MDF FRASSINO LIS BRANCO SYNCRO</option>
	  <option value="MDF FRASSINO STONE">MDF FRASSINO STONE</option>
      <option value="MDF GENGIBRE TATTO">MDF GENGIBRE TATTO</option>
	  <option value="MDF ITALIAN NOCE PORO">MDF ITALIAN NOCE PORO</option>
	  <option value="MDF LINEN GRIGIO VEL">MDF LINEN GRIGIO VEL</option>
	  <option value="MDF MADREPEROLA VEL">MDF MADREPEROLA VEL</option>
	  <option value="MDF MARFIM FLORENCA PORO">MDF MARFIM FLORENCA PORO</option>
	  <option value="MDF METALIC SUED TX">MDF METALIC SUED TX</option>
	  <option value="MDF NOCE MACCHIATTO PORO">MDF NOCE MACCHIATTO PORO</option>
	  <option value="MDF NOGAL MALAGA DESIGN">MDF NOGAL MALAGA DESIGN</option>
	  <option value="MDF NOGAL PALERMO PORO">MDF NOGAL PALERMO PORO</option>
	  <option value="MDF NOGAL SEVILHA PORO">MDF NOGAL SEVILHA PORO</option>
	  <option value="MDF NOGAL TURIM DESIGN">MDF NOGAL TURIM DESIGN</option>
	  <option value="MDF PEROBA TATTO">MDF PEROBA TATTO</option>
	  <option value="MDF PRETO DESIGN">MDF PRETO DESIGN</option>
	  <option value="MDF PRETO TX">MDF PRETO TX</option>
	  <option value="MDF PROVENCE TATTO">MDF PROVENCE TATTO</option>
	  <option value="MDF SALINA TATTO">MDF SALINA TATTO</option>
	  <option value="MDF SAVANA TATTO">MDF SAVANA TATTO</option>
	  <option value="MDF TAEDA DESIGN">MDF TAEDA DESIGN</option>
	  <option value="MDF WENGUE RAVENNA PORO">MDF WENGUE RAVENNA PORO</option>
	  <option value="MDF WENGUE VALENCIA PORO">MDF WENGUE VALENCIA PORO</option>
	  <option value="MDF WOOD TATTO">MDF WOOD TATTO</option>
	  <option value="COMPENSADO COMERCIAL - 2,20 X 1,60">COMPENSADO COMERCIAL - 2,20 X 1,60</option>
	  <option value="COMPENSADO SUMAÚMA - 2,20 X 1,60">COMPENSADO SUMAÚMA - 2,20 X 1,60</option>
	  <option value="COMPENSADO PARICÁ - 2,20 X 1,60">COMPENSADO PARICÁ - 2,20 X 1,60</option>
	  <option value="COMPENSADO VIROLA - 2,20 X 1,60">COMPENSADO VIROLA - 2,20 X 1,60</option>
	  <option value="COMPENSADO PARICÁ - 2,50 X 1,60">COMPENSADO PARICÁ - 2,50 X 1,60</option>
	  <option value="COMPENSADO SUMAÚMA - 2,50 X 1,60">COMPENSADO SUMAÚMA - 2,50 X 1,60</option>
	  
    </select>
  </div>
</div>

<div class="form-group-faces">
  <label class="col-md-1 control-label" for="selectbasic">Faces</label>
  <div class="col-md-4">
    <select id="select_faces" required="required" name="select_faces" class="form-control">
	  <option value=""></option>
	  <option value="CRU">CRU</option>
      <option value="1 FACE">1 FACE</option>
      <option value="2 FACES">2 FACES </option>
    </select>
  </div>
</div>

<div class="form-group-espessura">
  <label class="col-md-1 control-label" for="selectbasic">Espessura</label>
  <div class="col-md-4">
    <select id="select_espessura" required="required" name="select_espessura" class="form-control">
	  <option value=""></option>
	  <option value="3mm">3 mm</option>
      <option value="6mm">6 mm</option>
      <option value="9mm">9 mm</option>
	  <option value="15mm">15 mm</option>
      <option value="18mm">18 mm</option>
      <option value="20mm">20 mm</option>
	  <option value="25mm">25 mm</option>
    </select>
  </div>
</div>
   <h1></h1><br />
<!-- Select Basic -->

<!--TABELA-->
<table id="tblCadastro"> 
  <thead>
<h1>Cortes</h1>
  <tr>
    <th>QUANT.</th>
    <th data-th="Driver details"><span>Comp. (mm)</span></th>
    <th>Larg. (mm)</th>
    <th>&nbsp;Rotação&nbsp;</th>
    <th>Borda Sup.</th>
	<th>Borda Inf.</th>
    <th>Borda Dir.</th>
    <th>Borda Esq.</th>
	<th>Desc. Etiqueta</th>
	<th>Excluir</th>
  </tr>
    </thead>
	 <tbody id="tabela">
    <tr id="linhaParaClonar">
    <td><div class="tabela-quant">
		<div class="col-md-1">
		<input id="textinput_quant" name="textinput_quant[]"  required="required" type="text" class="form-control input-md"> 
		</div>
		   </div>
	</td>

    <td><div class="tabela-compr">
		<div class="col-md-1">
		<input id="textinput_compr" name="textinput_compr[]"  required="required"  type="text" class="form-control input-md"> 
		</div>
		   </div>
	</td>
	
    <td><div class="tabela-larg">
		<div class="col-md-1">
		<input id="textinput_larg" name="textinput_larg[]"  required="required"  type="text" class="form-control input-md"> 
		</div>
		   </div>
	</td>

    <td div class="tabela-rotacao">
    <select id="select_rotacao" name="select_rotacao[]" class="form-control">
	  <option value="NÃO">NÃO</option>
      <option value="SIM">SIM</option>
    </select>
  </div>
	</td>
	
	    <td div class="tabela-borda-sup">
    <select id="select_borda_sup" name="select_borda_sup[]" class="form-control">
	  <option value="NÃO">NÃO</option>
      <option value="SIM">SIM</option>
    </select>
  </div>
	</td>
	
	    <td div class="tabela-borda-inf">
    <select id="select_borda_inf" name="select_borda_inf[]" class="form-control">
	  <option value="NÃO">NÃO</option>
      <option value="SIM">SIM</option>
    </select>
  </div>
	</td>
	
	    <td div class="tabela-borda-dir">
    <select id="select_borda_dir" name="select_borda_dir[]" class="form-control">
	  <option value="NÃO">NÃO</option>
      <option value="SIM">SIM</option>
    </select>
  </div>
	</td>
	
	    <td div class="tabela-borda-esq">
    <select id="select_borda_esq" name="select_borda_esq[]" class="form-control">
	  <option value="NÃO">NÃO</option>
      <option value="SIM">SIM</option>
    </select>
  </div>
	</td>
	
	    <td><div class="tabela-larg">
		<div class="col-md-1">
		<input id="textarea_etiqueta" name="textarea_etiqueta[]" type="text" class="form-control input-md"> 
		</div>
		   </div>
	</td>
	    <td><a href="javascript:void(0);" onclick="deletarLinha()" title="Excluir"><img src="http://www.norteplac.com.br/wp-content/themes/i-max/images/recycle.png" widht="32px" height="32px" border="0" align="center"></img></a></td>
</tr><!--FIM DA LINHA DA TABELA-->
  </tbody>
</table>
<!--FIM DIV TABELA-->
<div id="botao-add">
<input type="button" onclick="clonarLinha()" value="+ Cortes" />
</div>
<!-- Text input-->
<div class="form-group-obs">
  <label class="col-input-obs" for="textarea">Observaçoes</label>  
  <div class="col-md-obs">
 		<textarea id="textarea_obs" name="textarea_obs" type="text" class="form-control-obs"></textarea> 
  </div>
</div>

<div id="botoes">
<!-- Button (Double) -->
<div class="form-group-botoes">
  <label class="col-md-4 control-label" for="button1id"></label>
  <div class="col-md-botoes">
    <button id="button1id" name="button1id" class="btn btn-success">Solicitar Plano de Corte</button>
	<button id="button3id" name="button2id" class="btn btn-danger">Cancelar</button>
  </div>
</div>
</div>

</form>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="http://www.norteplac.com.br/wp-content/themes/i-max/js/bootstrap.min.js"></script>

  </body>
</html>


<?php get_footer(); ?>

 

enviar.php

<?php
//Variaveis

$textinput_numero = $_POST['textinput_numero'];
$textinput_nome = $_POST['textinput_nome'];
$textinput_email = $_POST['textinput_email'];
$textinput_telefone = $_POST['textinput_telefone'];
$textinput_projeto = $_POST['textinput_projeto'];
$select_vendedor = $_POST['select_vendedor'];
$select_material = $_POST['select_material'];
$select_faces = $_POST['select_faces'];
$select_espessura = $_POST['select_espessura'];
$textarea_obs = $_POST['textarea_obs'];
$data_envio = date('d/m/Y');

$textinput_quant = $_POST['textinput_quant'];
$textinput_compr = $_POST['textinput_compr'];
$textinput_larg = $_POST['textinput_larg'];
$select_rotacao = $_POST['select_rotacao'];
$select_borda_sup = $_POST['select_borda_sup'];
$select_borda_inf = $_POST['select_borda_inf'];
$select_borda_dir = $_POST['select_borda_dir'];
$select_borda_esq =$_POST['select_borda_esq'];
$textarea_etiqueta = $_POST['textarea_etiqueta'];


// -------------

// Corpo E-mail

	
	$arquivo = "
	<style type='text/css'>
	body {
	margin:20px;
	font-family:Verdana;
	font-size:10px;
	color: #666666;
	}
	a{
	color: #666666;
	text-decoration: none;
	}
	a:hover {
	color: #FF0000;
	text-decoration: none;
	}
	</style>
    <html>
        <table width='510' border='1' cellpadding='1' cellspacing='1' bgcolor='#CCCCCC'>
            <tr>
              <td>
			  	<tr>
                 <td width='500'><b>Número:</b> $textinput_numero</td>
                </tr>
			    <tr>
                 <td width='500'><b>Nome:</b> $textinput_nome</td>
                </tr>
                <tr>
                  <td width='320'><b>E-mail:</b> $textinput_email</td>
	            </tr>
				<tr>
                  <td width='320'><b>Telefone:</b> $textinput_telefone</td>
                </tr>
				<tr>
                  <td width='320'><b>Projeto:</b> $textinput_projeto</td>
                </tr>
				<tr>
				<td width='320'><b>Vendedor:</b> $select_vendedor</td>
				</tr>
				<tr>
				<td width='320'><b>Material:</b> $select_material</td>
				</tr>
				<tr>
				<td width='320'><b>Faces:</b> $select_faces</td>
				</tr>
				<tr>
				<td width='320'><b>Espessura:</b> $select_espessura</td>
				</tr>
				<tr>
                  <td width='320'><b>OBS:</b> $textarea_obs</td>
                </tr>
            </td>
          </tr>  
          <tr>
            <td>Este e-mail foi enviado em <b>$data_envio</b></td>
          </tr>
        </table>
		<h2>CORTES</h2>
		<table width='810' border='1' cellpadding='1' cellspacing='1' bgcolor='#ffffff'>
            <tr>
              <td>
			    <tr>
                 <td width='50'><b>QTD</b></td>
				 <td width='80'><b>COMP. (mm)</b></td>
				 <td width='80'><b>LARG. (mm)</b></td>
				 <td width='50'><b>ROTAÇÃO</b></td>
				 <td width='50'><b>BORDA SUP.</b></td>
				 <td width='50'><b>BORDA INF.</b></td>
				 <td width='50'><b>BORDA DIR.</b></td>
				 <td width='50'><b>BORDA ESQ.</b></td>
				 <td width='50'><b>ETIQUETA</b></td>
                </tr>
			    <tr>
                 <td width='50'>$textinput_quant</td>
				 <td width='80'>$textinput_compr</td>
				 <td width='80'>$textinput_larg</td>
				 <td width='50'>$select_rotacao</td>
				 <td width='50'>$select_borda_sup</td>
				 <td width='50'>$select_borda_inf</td>
				 <td width='50'>$select_borda_dir</td>
				 <td width='50'>$select_borda_esq</td>
				 <td width='50'>$textarea_etiqueta</td>

                </tr>
            </td>
          </tr>  
        </table>
    </html>
	";

// -------------------------

//enviar
	
	// emails para quem será enviado o formulário
	$email = $select_vendedor;
	switch($select_vendedor){

case 'INDIFERENTE':
$email = '[email protected]';
break;

case 'ALEXANDRE':
$email = '[email protected]';
break;

case 'CANA':
$email = '[email protected]';
break;

case 'GEOVÂNIA':
$email = '[email protected]';
break;

case 'KLEBER':
$email = '[email protected]';
break;

case 'TINICO':
$email = '[email protected]';
break;

case 'VERA':
$email = '[email protected]';
break;

}
	$destino = $email;
	$assunto = "Plano de Corte via Site";

	// É necessário indicar que o formato do e-mail é html
	$headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-UTF-8' . "\r\n";
    $headers .= 'From: Norteplac Madeiras <[email protected]>';
	//$headers .= "Bcc: $EmailPadrao\r\n";
	
	$enviaremail = mail($destino, $assunto, $arquivo, $headers);
	if($enviaremail){
	$mgm = "E-MAIL ENVIADO COM SUCESSO! <br> O link será enviado para o e-mail fornecido no formulário";
	echo " <meta http-equiv='refresh' content='1;URL=/plano-de-corte'>";
	echo "<script>alert('Seu Plano de Corte foi enviado com sucesso!');</script>";
	} else {
	$mgm = "ERRO AO ENVIAR E-MAIL!";
	echo "";
	}
?>

 

Edited by Esvaldo Marcos
Faltou conteudo

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this