NEcesito un formulario de contacto en html..

minuto

Bovino adolescente
#1
hola bakunos,

quien me puede pasar un formulario de contacto en html, no logro conseguir, les agradeceria mucho...


saludos,
 

ki

Bovino adicto
#3
<html>
<body>
<form action=mailto:mimail@midominio.com>
Nombre:<input type=text name=nombre><br>
email:<input type=text name=correo><br>
<input type=submit>
</form>
</body>
</html>


algo asi?
 

minuto

Bovino adolescente
#4
muchas gracias ki,

lo necesito en php, que lleve cosas basicas como nombre, email, asunto, mensaje y sus botones, y si es posible que al final diga gracias o algo asi, se los agradeceria mucho, o al menos uno parecido!


saludos,
 

nean_degor

Bovino maduro
#5
Ahi te va..
hay una pagina que se llama phpclasses.org.. ahi encuentras de todo.. te recomiendo crear tu cuenta es gratuita..

esta la saque de ahi.. ahi te dejo de tarea el interpretarla.. no esta muy complicada..

SALUDOS!


<?php
// Contact form class to validate the mandatory fiends and send mail
// please change recipient address in line 128 and from address in line 132 and then use this contact form.
class Contactform
{
// function validate to validate the required fields which is indicated by *
function validate()
{

$errmsg=""; // initialize the errmsg to zero;
$newline="<br>";



if(!$this->validatename($_POST['name'])) // validate the name field , this function calls the validatename function
{

$errmsg.="Enter the name"."$newline";



}
if(!$this->validateemail($_POST['email'])) // validate the email field
{
$errmsg.="Enter the valid email id"."$newline";


}
if(!$this->validatephone($_POST['phone'])) // validate the phone field
{
$errmsg.="Enter the valie phone number"."$newline";


}
if(!$this->validatemessage($_POST['message'])) // validate the message
{
$errmsg.="Enter the message"."$newline";


}



return $errmsg; // return error message if any mistake in filling the form else it return null

}
function validatename($name) // this function to validate name
{


if(eregi("^[a-zA-Z0-9]+$","$name"))
{

return 1;

}
else
{

return 0;

}


}
function validateemail($email) // this function to validate email
{

if(eregi("^[a-z0-9_.]+@[a-z0-9\-]+\.[a-z0-9\-\.]+$","$email"))
{

return 1;

}
else
{

return 0;

}


}
function validatephone($phone) // this function to validate phone
{
if(eregi("^[+0-9]+$","$phone"))
{

return 1;

}
else
{

return 0;

}

}
function validatemessage($message) // this function to validate message
{
if($message)
{

return 1;

}
else
{

return 0;

}

}


function mailsend() // this function to send mail if the validation true
{
$msg = "Name\n $_POST[name]"; // assign all the post data fields to the variable
$msg .= "\n\nEmail\n $_POST";
$msg .= "\n\nTelephone\n $_POST[phone]";
$msg .= "\n\nMobile\n $_POST[mobile]";
$msg .= "\n\nCountry\n $_POST[country]";
$msg .= "\n\nCompany\n $_POST[company]";
$msg .= "\n\nMessage\n $_POST[message]";

//Setup the mail format
$recipient = "Recipientaddress"; // Recipient mail address
$subject = "Contact Form"; // subject of the mail
$mailheaders = "MIME-Version: 1.0\r\n";
$mailheaders .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$mailheaders .= "From:Your from address \r\n"; // from address fo the person
$mailheaders .= "Reply-To: $_POST[email]\r\n"; // reply field
//Send the contact form
$sent=mail($recipient, $subject, $msg,$mailheaders); // this function to send mail to the recpient
if($sent)
{
$rs="Your message has been sent successfully "; // display this message if the message sent successfully
return $rs;
}
else
{
$rs="Sorry, Some problem in server please try again later"; // display the error message if the message not sent
return $rs;
}

}

};
$name=$_POST['name'];
$phone=$_POST['phone'];
$message=$_POST['message'];
$email=$_POST['email'];
$mobile=$_POST['mobile'];
$country=$_POST['country'];
$company=$_POST['company'];

$obj=new Contactform(); //create object to the Contactform class
if($_POST['submit']) // if the user click the submit button this loop will execute
{

$rs=$obj->validate(); // call the validate function using the object
if($rs=="")

{
$confirm=$obj->mailsend(); // if the validation succeed, call the sendmail() function
echo "<center>$confirm</center>"; // display the confirmation message


}

}


echo "<center>$rs</center>"; // display the error message, if the user left any or enter invalid data

// display the form using heredoc syntax
$formdis = <<< EOT
<form name='f1' method='post' action=''>
<br>
<table width='487' border='0' align='center' cellpadding='0' cellspacing='0'>
<tr>
<td width='483' scope='row'><table width='100%' border='0' cellpadding='2' cellspacing='2' >
<tr>
<td width='23%' bgcolor='' scope='row'><div align='center'><span class='style7'>Name </span></div></td>
<td width='52%' bgcolor=''><input type='text' name='name' value="$name" maxlength='50' size=40
/></td>
<td width='25%' bgcolor='' id='inf_from'><span class='style20'>*</span></td>
</tr>
<tr>
<td bgcolor='#FFFFFF' scope='row'><div align='center'><span class='style7'>Email</span></div></td>
<td bgcolor='#FFFFFF'><input type='text' name='email' id='email' value="$email" maxlength='50' size=40
/></td>
<td bgcolor='#FFFFFF' id='inf_email'><span class='style20'>*</span></td>
</tr>
<tr>
<td bgcolor='' scope='row'><div align='center'><span class='style7'>Telephone</span></div></td>
<td bgcolor=''><input type='text' name='phone' value="$phone" size='40' maxlength='25'
/></td>
<td bgcolor='' id='inf_telnr'><span class='style20'>*</span></td>
</tr>
<tr>
<td bgcolor='#FFFFFF' class='style7'><div align='center'>Mobile</div></td>
<td bgcolor='#FFFFFF'><input type='text' name='mobile' value="$mobile" size=40
/></td>
<td width='25%' bgcolor='#FFFFFF' id='adr_from'>&nbsp;</td>
</tr>
<tr>
<td bgcolor='' scope='row'><div align='center'><span class='style7'>Country</span> </div></td>
<td bgcolor=''><input type='text' name='country' size=40 value="$country" /></td>
<td width='25%' bgcolor='' id='st_from'>&nbsp;</td>
</tr>
<tr>
<td bgcolor='#FFFFFF' scope='row'><div align='center'><span class='style7'>Company</span></div></td>
<td bgcolor='#FFFFFF' scope='row'><input type='text' name='company' value="$company" size='40' /></td>
<td bgcolor='#FFFFFF' scope='row'>&nbsp;</td>
</tr>
<tr>
<td bgcolor='' class='style9' scope='row'><div align='center' class='style18'>Message</div></td>
<td bgcolor='' scope='row'><label>
<textarea name='message' id='message' rows=6 cols=30 >$message</textarea>
</label></td>
<td bgcolor='' scope='row'>&nbsp;</td>
</tr>
</table>

</table>
<table width='487' border='0' align='center' cellpadding='2' cellspacing='2'>
<tr>
<td width='274' scope='row' align='right'>
<input name='submit' type='submit' value='Submit' ></td>

</tr>
</table>
</form>
EOT;
echo $formdis;


?>
 
Arriba