Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
boa tarde a todos,
este formulario estava funcionando 100% com os seguintes valores:
Nome
assunto
mensagem
porem eu preciso de 2 campos diferentes, telefone e um checkbox com tipos de servicos.
Eu nao entendo nada de php, ja peguei esse formulario pronto.
Esta dando os seguintes erros:
( ! ) Deprecated: Function eregi() is deprecated in C:\wamp\www\html\contact\index.php on line 22
Call Stack
# Time Memory Function Location
1 0.0005 708568 {main}( ) ..\index.php:0
( ! ) Notice: Undefined index: jobtype in C:\wamp\www\html\contact\index.php on line 48
Call Stack
# Time Memory Function Location
1 0.0005 708568 {main}( ) ..\index.php:0
( ! ) Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\html\contact\index.php on line 56
Call Stack
# Time Memory Function Location
1 0.0005 708568 {main}( ) ..\index.php:0
2 0.0009 710288 mail ( ) ..\index.php:56
line 22:
} else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) {
line 48
'jobtype: '.$_POST['jobtype'].PHP_EOL.
line 56
mail($emailTo, $subject, $body, $headers);
agora parte inteira da pagina.php
<?php
//If the form is submitted
if(isset($_POST['submit'])) {
//Check to make sure that the name field is not empty
if(trim($_POST['contactname']) == '') {
$hasError = true; $name = trim($_POST['contactname']);
}
//Check to make sure that the phone field is not empty
if(trim($_POST['phone']) == '') {
$hasError = true; $phone = trim($_POST['phone']);
}
//Check to make sure sure that a valid email address is submitted
if(trim($_POST['email']) == '') {
$hasError = true;
} else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) {
$hasError = true; $email = trim($_POST['email']);
}
//Check to make sure comments were entered
if(trim($_POST['message']) == '') {
$hasError = true; if(function_exists('stripslashes')) {
$comments = stripslashes(trim($_POST['message']));
} else {
$comments = trim($_POST['message']);
}
}
//If there is no error, send the email
if(!isset($hasError)) {
$emailTo = 'mhqmelo@gmail.com'; //Put email address here.
$subject = 'ZOMER WEBSITE COMMENT';
$body = 'Name: '.$_POST['contactname'].PHP_EOL.
'email: '.$_POST['email'].PHP_EOL.
'phone: '.$_POST['phone'].PHP_EOL.
'jobtype: '.$_POST['jobtype'].PHP_EOL.
'comments: '.$_POST['message'];
$headers = "From: {$name} <{$email}>".PHP_EOL;
$headers .= "Reply-To: {$email}".PHP_EOL;
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'X-Mailer: PHP '. phpversion();
mail($emailTo, $subject, $body, $headers);
$emailSent = true;
}
}
?><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='description' content='Painting & Carpentry Services in Boston Massachusetts'/>
<meta name='keywords' content='Paint Painting Carpentry Boston Massachusetts'/>
<meta name="google-site-verification" content="hl9_lQR3G2f7G8H3nA1xnpYealUiVbbCOvxTYD0VsdA" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<title>Zomer Painting & Carpentry - Boston Massachusetts</title>
<link rel="stylesheet" type="text/css" href="../css/main.css"/>
<script src="../scripts/DD_belatedPNG_0.0.7a.js" type="text/javascript"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.8/jquery.validate.js" type="text/javascript"></script><script type="text/javascript">
DD_belatedPNG.fix('img, #wrap-header, #wrap-content, #box-contact, #content-right, ul');
</script><script type="text/javascript">
$(document).ready(function(){
$("li a[href='"+location.href.substring(location.href.lastIndexOf("/")+1,255)+"']").css("color","#FFF");
});
</script><script type="text/javascript">
$(document).ready(function(){
$("#contactform").validate();
});
</script
></head>
<div id="wrap-content-model">
<div id="left-contact-content">
<h3>If you have any comment or need to make an appoitment, contact us via the form below:</h3>
<div id="contact-wrapper" class="border-top">
<?php if(isset($hasError)) { //If errors are found ?>
<p class="error">Please check if you've filled all the fields with valid information. Thank you.</p>
<?php } ?>
<?php if(isset($emailSent) && $emailSent == true) { //If email is sent ?>
<p><strong>Email Successfully Sent!</strong></p>
<p>Thank you <strong><?php echo $name;?></strong> for using my contact form! Your email was successfully sent and I will be in touch with you soon.</p>
<?php } ?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" id="contactform">
<div>
<label for="name"><strong>Name:</strong></label>
<input type="text" size="70" name="contactname" id="contactname" value="" class="required" />
</div>
<div>
<label for="email"><strong>Email:</strong></label>
<input type="text" size="70" name="email" id="email" value="" class="required email" />
</div>
<div>
<label for="phone"><strong>Contact Number:</strong></label>
<input type="text" size="70" name="phone" id="subject" value="" class="required" />
</div>
<div>
<label for="jobtype"><strong>Type of work needed: [select all that apply]</strong></label>
<input type="checkbox" name="jobtype" value=""/><span class="p-checkbox">Internal Painting</span><br />
<input type="checkbox" name="jobtype" value=""/><span class="p-checkbox">Exterior Painting</span><br />
<input type="checkbox" name="jobtype" value=""/><span class="p-checkbox">Carpentry</span><br />
<input type="checkbox" name="jobtype" value=""/><span class="p-checkbox">Both Painting & Carpentry</span>
</div>
<div>
<label for="message"><strong>Message:</strong></label>
<textarea rows="8" cols="80" name="message" id="message" class="required"></textarea>
</div>
<input type="submit" value="Send Message" name="submit" />
</form>
</div><!-- /Contact wrapper -->
agradeco a ajuda.
Lebrando que neste formulario, eu recebo os dados dos campos como informei acima, mais quando acrescendo o telefone e a checkbox, nada funciona mais e eu nao recebo nada.
Carregando comentários...