Foros del Web » Programando para Internet » PHP »

Formulario php.. ni idea

Estas en el tema de Formulario php.. ni idea en el foro de PHP en Foros del Web. Bueno ahora me encuentro que mi servidor no soporta asp y me veo en la necesidad de cambiar todo para php y aprender a marcha ...
  #1 (permalink)  
Antiguo 22/04/2007, 12:28
 
Fecha de Ingreso: abril-2006
Mensajes: 123
Antigüedad: 18 años
Puntos: 0
Formulario php.. ni idea

Bueno ahora me encuentro que mi servidor no soporta asp y me veo en la necesidad de cambiar todo para php y aprender a marcha forzada. He medio buscado medio cambiado y medio arreglado el siguiente formulario, por favor si me lo pueden encaminar lo agradeceria.

Lo que deseo es un formulario donde se puedan añadir animales perdidos, con datos de obligado cumplimiento como el email y asegurarse que pongan un la direccion correcta, al añadir la fecha de perdida que sea un formato de fecha.. ademas se tiene que permitir el enviar una foto, todo esto a mi email, yo normalmente lo hacia mediante formmail, aqui ya me pierdo...

este es el formulario:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "ww.w3.org/TR/html4/loose.dtd">

<html xmlns="ww.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<TITLE>Añadir Mascota Extraviada</TITLE>
<meta name="keywords" content="peluqueria canina de tenerife, peluquera canina de tenerife, peluqueria canina de canarias, peluquera profesional de tenerife">
<meta name="description" content="Añadir mascota perdida, anuncios de perros perdidos, peluqueria canina de tenerife, gatos perdidos">
</HEAD>
<BODY text="#FFFFFF" bgcolor="#800000">


<?php
if ($_SERVER['REQUEST_METHOD']=="POST"){

// we'll begin by assigning the To address and message subject
// $to="[email protected]";
$to=$_POST['acorreo'];

//$subject="E-mail with attachment";
$subject=$_POST['asunto'];
// get the sender's name and email address
// we'll just plug them a variable to be used later
$from = stripslashes($_POST['fromname'])."<".stripslashes($_POST['fromemail']).">";

// generate a random string to be used as the boundary marker
$mime_boundary="==Multipart_Boundary_x".md5(mt_ran d())."x";

// store the file information to variables for easier access
$tmp_name = $_FILES['filename']['tmp_name'];
$type = $_FILES['filename']['type'];
$name = $_FILES['filename']['name'];
$size = $_FILES['filename']['size'];

// here we'll hard code a text messge
// again, in reality, you'll normally get this from the form submission
// $message = "Here is your file: $name";
$message = $_POST['mensaje'];

// if the upload succeded, the file will exist
if (file_exists($tmp_name)){

// check to make sure that it is an uploaded file and not a system file
if(is_uploaded_file($tmp_name)){

// open the file for a binary read
$file = fopen($tmp_name,'rb');

// read the file content into a variable
$data = fread($file,filesize($tmp_name));

// close the file
fclose($file);

// now we encode it and split it into acceptable length lines
$data = chunk_split(base64_encode($data));
}

// now we'll build the message headers
$headers = "From: $from\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: multipart/mixed;\r\n" .
" boundary=\"{$mime_boundary}\"";

// next, we'll build the message body
// note that we insert two dashes in front of the
// MIME boundary when we use it
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";

// now we'll insert a boundary to indicate we're starting the attachment
// we have to specify the content type, file name, and disposition as
// an attachment, then add the file content and set another boundary to
// indicate that the end of the file has been reached
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$type};\n" .
" name=\"{$name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";

// now we just send the message
if (@mail($to, $subject, $message, $headers)) {


echo "Correo enviado<br>";
echo "<a href='ww.tupeluqueriacanina.com/web.html'>ww.tupeluqueriacanina.com/web.html</a><br>";

}
else
echo "Fallo en el envío";
}
} else {
?>



<p align="right"><font face="Verdana" size="1">tupeluqueriacanina.com</font></p>
<p align="center"><font face="Verdana" size="5">Rellena el siguiente formulario<br>
</font><font face="Verdana" size="4">para añadir a tu mascota<BR>

</font></p>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"
enctype="multipart/form-data" name="form1">



<p align="center"><u><font face="Roman" size="5">Datos del Animal</font></u></p>
<table border="1" width="100%" id="table1">
<tr>
<td align="center"><font face="Verdana">
<label>

Especie:
<SELECT NAME="select" id="especie">
<OPTION VALUE=" Perro ">Perro
<OPTION VALUE=" Gato ">Gato
</SELECT>
</font></font></td>

<td align="center"><font face="Verdana">

Raza:
<INPUT TYPE="Text" NAME="raza"

</font></font></td>

</tr>
<tr>
<td align="center"><font face="Verdana">

Nombre:
<INPUT TYPE="Text" NAME="nombre" SIZE=27>

</font></font></td>

<td align="center">
<p align="center"><font face="Verdana">


Sexo:
<SELECT NAME="sexo" id="sexo">

<OPTION VALUE="Macho ">Macho
<OPTION VALUE="Hembra ">Hembra
</SELECT>


</font></font></td>
</tr>
</table>



<p align="center"><font face="Verdana"><BR></font><u>
<font face="Roman" size="5">Datos de la Perdida</font><font face="Roman"><BR>
</font></u><font face="Verdana"><BR>

Fecha de la Perdida: <font size="3">
<INPUT TYPE="Text" NAME="fechadelaperdida" SIZE=30>

</font></font></p>
<table border="1" width="100%" id="table2">
<tr>
<td align="center"><font face="Verdana">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;

País: <font size="3"> <INPUT TYPE="Text" NAME="pais" SIZE=27></font></font></td>
<td align="center"><font face="Verdana">

Provincia: <font size="3">
<INPUT TYPE="Text" NAME="provincia" SIZE=23></font> </font></td>
</tr>
<tr>
<td align="center"><font face="Verdana">

Municipio: <font size="3">
<INPUT TYPE="Text" NAME="municipio" SIZE=27></font> </font></td>
<td align="center"><font face="Verdana">&nbsp;&nbsp;&nbsp;&nbsp;

Zona:
<font size="3"> <INPUT TYPE="Text" NAME="zona" SIZE=23></font>
</font></td>
</tr>
</table>
<p align="center"><font face="Verdana">

Email del Contacto: <font size="3">
<INPUT TYPE="Text" NAME="email" SIZE=28></font> </font></p>
<p align="center"><font face="Verdana"><BR>
<font size="3">

Enviar Foto: <input type="file" name="filename"></font></p><br>
<p align="center">
<INPUT TYPE="Submit" NAME="enviar" VALUE="Enviar" SIZE=8></font><BR><BR>
&nbsp; </font></p>

</FORM>
<?php } ?>
</BODY>
</HTML>


Tengo que recortar algunos enlaces y ponerlos como ww. ??? porque el foro no me permite ponerlos enteros
  #2 (permalink)  
Antiguo 22/04/2007, 13:29
 
Fecha de Ingreso: abril-2007
Mensajes: 54
Antigüedad: 17 años
Puntos: 1
Re: Formulario php.. ni idea

Te recomiendo el NUSPHERE para debugar el codigo php.

E ir poco a poco adaptando tu codigo ASP y comprobando que funcione. Me gustaria poder hacertelo, pero entre que apenas te ayudaria y que no tengo tiempo porque tengo un viaje no peudo hacerlo.

Recuerda NUSPHERE PHP EDIT, me va muy bien, incluso el dreamweaver mismo y ya si te pones un FIREFOX de navegador ni te cuento lo facil que veras los errores. (FIREFOX--herramientas-consola errores)
  #3 (permalink)  
Antiguo 22/04/2007, 13:32
 
Fecha de Ingreso: abril-2007
Mensajes: 54
Antigüedad: 17 años
Puntos: 1
De acuerdo Re: Formulario php.. ni idea

pd: una web muy buena que te explica perfecto y ademas son fans de padre de familia xD

ww.w3schools.com


son 3 W.

Perfecta para aprender lo que quieras
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 03:20.