matheusrf Posted November 28, 2016 Share Posted November 28, 2016 Hi, good day for all, I'm having trouble submitting attachment and form informations by mail. The script sends only the mobile information. Can anyone help me on what is wrong? I need to send the email with/without attachment and sabe the informations in the database. <?php header('Content-Type: text/html; charset=utf-8'); // Inclui o arquivo que faz a conexão ao MySQL include('Connections/commercial.php'); mysql_query("SET NAMES 'utf8'"); mysql_query('SET character_set_connection=utf8'); mysql_query('SET character_set_client=utf8'); mysql_query('SET character_set_results=utf8'); // Manipulamos as variáveis para evitar problemas com aspas e outros caracteres protegidos do MySQL $hoje_tmp = getdate(); $email_from = $_POST["email"]; $cellphone = $_POST["cellphone"]; $consuption = $_POST["consuption"]; $cep = $_POST["cep"]; $product = $_POST["product"]; $roof = $_POST["roof"]; $assunto = $_POST["subject"]; $client = $_POST["name"]; $email = "automatic@automatic.com.br"; //pego os dados enviados pelo formulario $arquivo = isset($_FILES["arquivo"]) ? $_FILES["arquivo"] : FALSE; if(file_exists($arquivo["tmp_name"]) and !empty($arquivo)){ $fp = fopen($_FILES["arquivo"]["tmp_name"],"rb"); $anexo = fread($fp,filesize($_FILES["arquivo"]["tmp_name"])); $anexo = base64_encode($anexo); fclose($fp); $anexo = chunk_split($anexo); $boundary = "XYZ-" . date("dmYis") . "-ZYX"; $mens = "--$boundary\n"; $mens .= "Content-Transfer-Encoding: 8bits\n"; $mens .= "Content-Type: text/html; charset=\"utf-8\"\n\n"; //plain $mens .= "<p>Nome: $client</p>" . "<p>Cellphone: $cellphone</p>" . "<p>Consumo: $consuption</p>" . "<p>CEP: $cep</p>" . "<p>Telhado: $roof</p>" . "<p>Produto: $product\n</p>"; $mens .= "--$boundary\n"; $mens .= "Content-Type: ".$arquivo["type"]."\n"; $mens .= "Content-Disposition: attachment; filename=\"".$arquivo["name"]."\"\n"; $mens .= "Content-Transfer-Encoding: base64\n\n"; $mens .= "$anexo\n"; $mens .= "--$boundary--\r\n"; $headers = "MIME-Version: 1.0\n"; $headers .= "From: \"$name\" <$email_from>\r\n"; $headers .= "Content-type: multipart/mixed; boundary=\"$boundary\"\r\n"; $headers .= "$boundary\n"; //envio o email com o anexo mail($email,$assunto,$mens,$headers); echo('Enviado com sucesso!'); } //se não tiver anexo else{ $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: \"$nome\" <$email_from>\r\n"; //envia o email sem anexo mail($email,$assunto,$cellphone, $headers); echo('Enviado com sucesso!'); } $client = mysql_escape_string($client); $cep = mysql_escape_string($cep); $email_from = mysql_escape_string($email_from); $cellphone = mysql_escape_string($cellphone); $product = mysql_escape_string($product); // Montamos a consulta SQL $query1 = "INSERT INTO `sales_clients` (`name`, `email`, `cellphone`, `cep`, `product`, `roof`, `consuption_average`) VALUES ('".$client."', '".$email_from."', '".$cellphone."', '".$cep."', '".$product."', '".$roof."', '".$consuption."')"; // Executa a query $inserir = mysql_query($query1); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Tupã</title> <script type="text/javascript"> window.setTimeout("location.href='index.php';", 2500); </script> </head> <body> </body> </html> Quote Link to comment Share on other sites More sharing options...
benanamen Posted November 28, 2016 Share Posted November 28, 2016 You are using obsolete insecure code that has been completely removed from Php. You need to be using PDO. Update your code and we will be happy to help. https://phpdelusions.net/pdo Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.