help with input type

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cris_300
Forum Newbie
Posts: 5
Joined: Thu May 21, 2009 10:40 am

help with input type

Post by cris_300 »

i have a form
that send me an email whith an attachment

but two funtions have problems

this is the php code: (the two funtions are line 9 and line 59)
if i cut "$name_of_uploaded_file" then the explorer page said "Call to undefined function getuploadedfileinfo() "

please help me!

php

Code: Select all

 
if(isset($_POST[uploaded_file]) && $_POST[uploaded_file]!="") {
 
   $name_of_uploaded_file="No ingreso archivo adjunto" ;
 
   include_once('Mail.php');
   include_once('mime.php');
   
function ComposeMail($name_of_uploaded_file){
   $name = $_POST['nombre'];
   $user_message = $_POST['descripcion'];
   $to = "cristina.arias.ing@gmail.com";
   $subject="Una nueva solicitud fue realizada";
   $from = $_POST['correo'];
   $ubi = $_POST['ubicacion'];
   $tel = $_POST['telefono'];
   $emp = $_POST['empresa'];
   $text = "Haz recibido de: " . $name ."\n"."Ubicado en:".$ubi."\n"."Telefono:".$tel. "\n"."Empresa:".$emp. "\n"."Envio lo     
   siguiente: ".
   $user_message;
   $message = new Mail_mime(); 
   $message->setTXTBody($text); 
   $body = $message->get();
   $extraheaders = array("From"=>$from, "Subject"=>$subject);
   $headers = $message->headers($extraheaders);
   $mail = Mail::factory("mail");
   $mail->send($to, $headers, $body);
   echo "Tu solicitud de cotizaci&oacute;n fue enviada exitosamente". "\n"."A la mayor brevedad te responderemos.<a    
   href='index.html'>Regresar a inicio</a>";
 }
}
 else  {
 
 
$max_allowed_file_size = "5000"; // this is size in KB 
list($name_of_uploaded_file, $type_of_uploaded_file, $size_of_uploaded_file) = GetUploadedFileInfo();
if(!Validate($name_of_uploaded_file, $type_of_uploaded_file, $size_of_uploaded_file, $max_allowed_file_size)) {
   exit();
}
LoadUploadedFile($name_of_uploaded_file);
$path_of_uploaded_file = "uploads/" . $name_of_uploaded_file;
 
   include_once('Mail.php');
   include_once('mime.php');
 
ComposeMail($path_of_uploaded_file);
 
 
//////////////////// Functions ////////////////////////
 
function GetUploadedFileInfo() {
   $file_info[] = basename($_FILES['uploaded_file']['name']);
   $file_info[] = substr($file_info[0], strrpos($file_info[0], '.') + 1);
   $file_info[] = $_FILES["uploaded_file"]["size"]/1024;
   return $file_info;
}
 
 
function Validate($name_of_uploaded_file, $type_of_uploaded_file, $size_of_uploaded_file, $max_allowed_file_size) {
   if($size_of_uploaded_file>$max_allowed_file_size ) {   echo " El tamano del archivo debe ser menor que" . $max_allowed_file_size . " KB. <a href='cotizacion.html'>Elija un archivo mas pequeno</a>";
      return false;
   }
$allowed_extension = array("jpg", "jpeg", "gif", "bmp" , "dwg" , "doc", "text" , "xls" , "pdf");
for($i=0; $i<sizeof($allowed_extension); $i++) { 
   $allowed_extension[$i] = strtoupper($allowed_extension[$i]); 
}
$type_of_uploaded_file = strtoupper($type_of_uploaded_file);
if(!(in_array(strtoupper($type_of_uploaded_file),$allowed_extension))) {
   echo "Tu archivo tiene extensi&oacute;n:" . $type_of_uploaded_file . " . Este tipo de archivo no esta permitido. Favor elija un archivo de extension de imagen (jpg,gif,etc), pdf, autocad, excel, word o rar. <a href='cotizacion.html'>De click a qui para enviar un archivo con extension permitida.</a>";
   return false;
}
   return true;
}
 
 
function LoadUploadedFile($name_of_uploaded_file) {
   move_uploaded_file($_FILES["uploaded_file"]["tmp_name"], "uploads/" . $name_of_uploaded_file);
   return true;
}
 
 
function ComposeMail($name_of_uploaded_file) {
   $name = $_POST['nombre'];
   $user_message = $_POST['descripcion'];
   $to = "cristina.arias.ing@gmail.com";
   $subject="Una nueva solicitud fue realizada";
   $from = $_POST['correo'];
   $ubi = $_POST['ubicacion'];
   $tel = $_POST['telefono'];
   $emp = $_POST['empresa'];
   $text = "Haz recibido de: " . $name ."\n"."Ubicado en:".$ubi."\n"."Telefono:".$tel. "\n"."Empresa:".$emp. "\n"."Envio lo siguiente: ".
   $user_message;
   $message = new Mail_mime(); 
   $message->setTXTBody($text); 
   $message->addAttachment($name_of_uploaded_file);
   $body = $message->get();
   $extraheaders = array("From"=>$from, "Subject"=>$subject);
   $headers = $message->headers($extraheaders);
   $mail = Mail::factory("mail");
   $mail->send($to, $headers, $body);
   echo "Tu solicitud de cotizaci&oacute;n fue enviada exitosamente". "\n"."A la mayor brevedad te responderemos.<a href='index.html'>Regresar a inicio</a>";
 
    }
       }
?>
 
Last edited by cris_300 on Thu May 21, 2009 11:10 am, edited 5 times in total.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: help with input type

Post by onion2k »

Those can't be fixed.
cris_300
Forum Newbie
Posts: 5
Joined: Thu May 21, 2009 10:40 am

Re: help with input type

Post by cris_300 »

hi again

i modified the code

now is this i cut the funtion that validate the type of archive to attachment

but there is other problems

the explorer windows said that is the last line "?>"

buy i dont see it

if somebody tell me pleaseeeeeeeee help meeee

Code: Select all

 <?
$max_allowed_file_size = "5000"; // this is size in KB 
list($name_of_uploaded_file, $size_of_uploaded_file) = GetUploadedFileInfo();
if(!Validate($name_of_uploaded_file, $size_of_uploaded_file, $max_allowed_file_size)) {
   exit();
}
LoadUploadedFile($name_of_uploaded_file);
$path_of_uploaded_file = "uploads/" . $name_of_uploaded_file;
 
   include_once('Mail.php');
   include_once('mime.php');
 
ComposeMail($path_of_uploaded_file);
 
 
//////////////////// Functions ////////////////////////
 
function GetUploadedFileInfo() {
   $file_info[] = basename($_FILES['uploaded_file']['name']);
    $file_info[] = $_FILES["uploaded_file"]["size"]/1024;
   return $file_info;
}
 
 
function Validate($name_of_uploaded_file, $size_of_uploaded_file, $max_allowed_file_size) {
   if($size_of_uploaded_file>$max_allowed_file_size ) {
       echo " El tamano del archivo debe ser menor que" . $max_allowed_file_size . " KB. <a href='cotizacion.html'>Elija un archivo mas pequeno</a>";
      return false;
   }
 
 
function LoadUploadedFile($name_of_uploaded_file) {
   move_uploaded_file($_FILES["uploaded_file"]["tmp_name"], "uploads/" . $name_of_uploaded_file);
   return true;
}
 
 
function ComposeMail($name_of_uploaded_file) {
   $name = $_POST['nombre'];
   $user_message = $_POST['descripcion'];
   $to = "cristina.arias.ing@gmail.com";
   $subject="Una nueva solicitud fue realizada";
   $from = $_POST['correo'];
   $ubi = $_POST['Ubicacion'];
   $tel = $_POST['telefono'];
   $text = "A user " . $name ."Ubicado en:".$ubi."Telefono:".$tel. "Envio lo siguiente: " . $user_message;
   $message = new Mail_mime(); 
   $message->setTXTBody($text); 
   $message->addAttachment($name_of_uploaded_file);
   $body = $message->get();
   $extraheaders = array("From"=>$from, "Subject"=>$subject);
   $headers = $message->headers($extraheaders);
   $mail = Mail::factory("mail");
   $mail->send($to, $headers, $body);
   echo "Tu solicitud fue enviada exitosamente.";}   
?>  
Last edited by Benjamin on Thu May 21, 2009 4:10 pm, edited 1 time in total.
Reason: Changed code type from text to php.
cris_300
Forum Newbie
Posts: 5
Joined: Thu May 21, 2009 10:40 am

Re: help with input type

Post by cris_300 »

please excuse me moderator but this code
try to become me crazy and
i need help

im new in php code

thanks!
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: help with input type

Post by califdon »

Sorry, but you are really not explaining your problem so that we can help you. At least I can't understand what you are saying.
cris_300
Forum Newbie
Posts: 5
Joined: Thu May 21, 2009 10:40 am

Re: help with input type

Post by cris_300 »

the explorer windows said that is the last line "?>"
has error

Parse error: syntax error, unexpected $end in /home/igdomco/public_html/send-email-form.php on line 57

i dont understand because is the end
Post Reply