Ce are?
Scris: 10-Mai-2008, 19:23:58
Deci,am facut rost de niste coduri html si un cod php.
Adica, contact.html si handle_contact.php.
Bun,bagati cfbraila.ro/contact.html si completati la vrajeala campurile de acolo si dati pe "send".Nu stiu de ce dar va arata ca nu ati pus nici un subiect la mesaj deci ati completat toate campurile.
Pote fi de la:
Am facut si acel ultim fisier,contact_done.html,in fine uitati tot codul:
Sper sa ma ajutati,:*
Adica, contact.html si handle_contact.php.
Bun,bagati cfbraila.ro/contact.html si completati la vrajeala campurile de acolo si dati pe "send".Nu stiu de ce dar va arata ca nu ati pus nici un subiect la mesaj deci ati completat toate campurile.
Pote fi de la:
Cod: Selectaţi tot
/*In the code below 2 variables are set, one is the email address the mail will be sent
to, and the other who to CC.*/
$sendTo = 'office@cfbraila.ro';
$Bcc = 'example@example.com';
Cod: Selectaţi tot
<?php
/**
* this script accompanies the tutorial available at www.stefashwell.com
*
* @author Stefan Ashwell <stef@stefashwell.com>
* @copyright stefashwell.com
* @written December 8th 2005
*/
/*The following will get the value entered into the "name" box on the contact form
as the form uses method="post" we use $_POST['name'] to get the value the code puts
it into a variable called 'name' for use later*/
$name = $_POST['name'];
/*The following "if" statement checks if there is a value in the variable $name, if
not it means nothing was entered into the box on the form, and so it will echo out
an error message and stop.
This isn't really necessary, and on some things you wont want to check.*/
if ( empty($name) ) {
echo 'You did not enter your name, please <a href="contact.html">go back</a> and make sure you enter it';
die();
}
/*Now lets capture the rest of the form elements and provide error checking for each
in the same way as above:*/
$company = $_POST['company'];
if ( empty($company) ) {
echo 'You did not enter your company, please <a href="contact.html">go back</a> and make sure you enter it';
die();
}
$email = $_POST['email'];
if ( empty($email) ) {
echo 'You did not enter your email address, please <a href="contact.html">go back</a> and make sure you enter it';
die();
}
$tel = $_POST['tel']; // for tel and fax it might not be necessary for it to be entered and so can be left blank
$fax = $_POST['fax'];
$subject = $_POST['subject'];
if ( empty($subject) ) {
echo 'You did not enter a subject, please <a href="contact.html">go back</a> and make sure you enter it';
die();
}
$comments = $_POST['comments'];
if ( empty($comments) ) {
echo 'You did not enter any comments, please <a href="contact.html">go back</a> and make sure you enter it';
die();
}
/*Ok now the boring bit is over we can start putting together the email message that
will be sent ready for sending.
The following code creates a variable called $message and all of the variables from the
form are added, along with extra text to go in the mail. carriage returns are created
with "\n".*/
$message = 'Someone has filled out the contact form on your website' . "\n\n";
$message .= 'Name: ' . $name . "\n";
$message .= 'Company: ' . $company . "\n";
$message .= 'Email: ' . $email . "\n";
$message .= 'Tel: ' . $tel . "\n";
$message .= 'Fax: ' . $fax . "\n\n";
$message .= 'Comments: ' . "\n";
$message .= $comments;
/*In the code below 2 variables are set, one is the email address the mail will be sent
to, and the other who to CC.*/
$sendTo = 'office@cfbraila.ro';
$Bcc = 'example@example.com';
/*The code below sets message headers - from, reply to and bcc addresses.*/
$headers = 'From: Contact Form <' . $email . '>' . "\r\n" . 'Reply-To: ' . $email . "\r\n" . 'Bcc: ' . $Bcc . "\r\n";
/*Ok now we can send the mail! which is really simple in php:*/
mail($sendTo, $subject, $message, $headers);
/*Now the mail has been sent we can forward the browser to a confirmation page letting the
user know their mail has been sent.*/
header ("Location: contact_done.html");
/*And that's about it! All that is left to do is create the HTML file called contact_done.html.*/
?>