Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Olá pessoal,
estou com um problema.
include("class.mysql.php");
$user = $_POST['cpf'];
$sql = new conect;
$sql->bdOn();
$consultarbd = $sql->executaMyql("SELECT * FROM usuarios WHERE cpf= '$user'");
$registro_linha = $sql->Myql_num_rows($consultarbd);
if($registro_linha <= 0){
print("<script>alert('Não foi encontrado nenhum usuário com o CPF informado.');
location.href = '../administracao/action.boleto/insert.php?us=".base64_encode($user)."';
</script>");
}else{
$registro = $sql->Myql_fecth_array($consultarbd);
$cod = $registro['cod'];
$pathToSave = '../arquivos_pdf/boletos/';
//array dos arquivos -------------------------------------------------------------------
$i = 0;
$msg = array( );
$arquivos = array( array( ) );
foreach( $_FILES as $key=>$info ) {
foreach( $info as $key=>$dados ) {
for( $i = 0; $i < sizeof( $dados ); $i++ ) {
$arquivos[$i][$key] = $info[$key][$i];
}
}
}
$i = 1;
foreach( $arquivos as $file ) {
// Verificar se o campo do arquivo foi preenchido
if( $file['name'] != '' ) {
$arquivoTmp = $file['tmp_name'];
$arquivo = $pathToSave.$file['name'];
if( !move_uploaded_file( $arquivoTmp, $arquivo ) ) {
echo("<script>alert('Ocorreu um problema no envio de seus arquivo, tente novamente.');
location.href = '../administracao/boleto.php?us=".base64_encode($user)."';
</script>");
} else {
$sql->executaMyql("INSERT INTO boletos(id, cod, arquivos, data) VALUES ('','$cod','$arquivo','')");
}
}
}
echo("<script>alert('Boleto para o cliente: [ ".$user." ] foi adicionado com sucesso!');
location.href = '../administracao/boleto.php?us=".base64_encode($user)."';
window.parent.parent.parent.GB_hide();
</script>");
}
?>
No cod acima eu recebo os arquivo em array e faço o upload deles e gravo no bd, até ai tudo bem. mas no mesmo form eu preciso colocar 3 campos para que o usuario possa inserir as datas de validade para cada arquivo como você ve no cod abaixo:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="[http://www.w3.org/1999/xhtml">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../../css/estilo_interno_componentes.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" media="all" href="../../css/niceforms-default.css" />
<script language="javascript" type="text/javascript" src="../../js/niceforms.js"></script>
<script src="../../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script type="text/javascript">
function FormataCpf(campo, teclapres)
{
var tecla = teclapres.keyCode;
var vr = new String(campo.value);
vr = vr.replace(".", "");
vr = vr.replace("/", "");
vr = vr.replace("-", "");
tam = vr.length + 1;
if (tecla != 14)
{
if (tam == 4)
campo.value = vr.substr(0, 3) + '.';
if (tam == 7)
campo.value = vr.substr(0, 3) + '.' + vr.substr(3, 6) + '.';
if (tam == 11)
campo.value = vr.substr(0, 3) + '.' + vr.substr(3, 3) + '.' + vr.substr(7, 3) + '-' + vr.substr(11, 2);
}
}
</script>
<title></title>
<link href="../../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" name="form1" method="post" action="../../classes/class.upload_pdfs.php" class="niceform" enctype="multipart/form-data">
<table width="0%" border="0" align="center" cellpadding="0" cellspacing="0" class="sobTitulos">
<tr>
<td width="565" height="39"> </td>
</tr>
<tr>
<td><table width="0%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="47" class="texto_titulos_em_preto"><img src="../../images/btn1.png" width="47" height="46" align="absmiddle"></td>
<td width="10" class="texto_titulos_em_preto"> </td>
<td width="415" class="texto_titulos_em_preto">CADASTRAR BOLETO BANCÁRIO<br>
Você está logado como o Usuário: <?php echo("$user");?></td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><img src="../../images/img_adm/linha.png" width="497" height="2"></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><table width="0%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="494"><table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="305"><table width="0" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="117" class="texto_titulos_em_preto">Digite um CPF:</td>
<td width="10"> </td>
<td width="357"><span id="sprytextfield1">
<input type="text" name="cpf" id="cpf" maxlength="14" onkeyup="FormataCpf(this,event)"/>
<span class="textfieldRequiredMsg">Campo Obrigatório.</span></span></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td class="texto_embranco"><img src="../../images/spacer.gif" width="1" height="5" /></td>
</tr>
<tr>
<td class="texto_titulos_em_preto">Escolha seu Arquivo:</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><table width="0%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><input type="file" name="arquivo[]" id="arquivo[]" /></td>
<td> </td>
<td class="texto_pequenos_em_preto">Data de Vencimento:</td>
<td> </td>
<td><span id="sprytextfield2">
<input type="text" name="data[]" id="data[]" />
<span class="textfieldInvalidFormatMsg">Formato Inválido.</span></span></td>
</tr>
</table></td>
</tr>
<tr>
<td><img src="../../images/spacer.gif" width="1" height="5" /></td>
</tr>
<tr>
<td><table width="0%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><input type="file" name="arquivo[]" id="arquivo[]" /></td>
<td> </td>
<td><span class="texto_pequenos_em_preto">Data de Vencimento:</span></td>
<td> </td>
<td><span id="sprytextfield3">
<input type="text" name="data[]" id="data[]" />
<span class="textfieldInvalidFormatMsg">Formato Inválido.</span></span></td>
</tr>
</table></td>
</tr>
<tr>
<td><img src="../../images/spacer.gif" width="1" height="5" /></td>
</tr>
<tr>
<td><table width="0%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><input type="file" name="arquivo[]" id="arquivo[]" /></td>
<td> </td>
<td><span class="texto_pequenos_em_preto">Data de Vencimento:</span></td>
<td> </td>
<td><span id="sprytextfield4">
<input type="text" name="data[]" id="data[]" />
<span class="textfieldInvalidFormatMsg">Formato Inválido.</span></span></td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><img src="../../images/img_adm/linha.png" width="497" height="2"></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><input type="submit" name="button" id="button" value="Enviar" /></td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</form>
<script type="text/javascript">var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "custom", {isRequired:false, useCharacterMasking:true, pattern:"00/00/0000"});
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "custom", {isRequired:false, useCharacterMasking:true, pattern:"00/00/0000"});
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "custom", {isRequired:false, useCharacterMasking:true, pattern:"00/00/0000"});</script>
</body>
</html>
na parte da data eu coloquei como array tb, mas como devo receber e inserir no bd de acordo com os arquivos?
Fico no aguardo!
Carregando comentários...