This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Salut!
De curand mi-am terminat portofoliul si am hotarat ca formul de contact sa fie in php, ideea e ca nu prea stiu php si am hotarat sa ma folosesc de google.
Am gasit unul gata facut, l-am editat dupa id-urile si clasele mele dar nu functioneaza, gen, imi arata ca mail-ul s-a trimis dar nu il primesc.
COD:
<form id="fcf-form-id" action="contact-form-process.php" method="post">
<label>Name</label>
<input id="Name" class="input-field" type="text" name="Name" required>
<label>Subject</label>
<input id="Subject" class="input-field" type="text" name="Subject" required>
<label>Email</label>
<input id="Email" class="input-field" type="text" name="Email" required>
<label>Message</label>
<textarea id="Message" class="input-field" name="Message"></textarea>
<input id="submit-btn" type="submit" value="Send">
</form>
<?php
if (isset($_POST['Email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = ["[email protected]](mailto:"[email protected])";
$email_subject = "New form submissions";
function problem($error)
{
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br><br>";
echo $error . "<br><br>";
echo "Please go back and fix these errors.<br><br>";
die();
}
// validation expected data exists
if (
!isset($_POST['Name']) ||
!isset($\_POST\['Subject'\]) ||
!isset($_POST['Email']) ||
!isset($_POST['Message'])
) {
problem('We are sorry, but there appears to be a problem with the form you submitted.');
}
$name = $_POST['Name']; // required
$name = $\_POST\['Subject'\]; // required
$email = $_POST['Email']; // required
$message = $_POST['Message']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-] @[A-Za-z0-9.-] \.[A-Za-z]{2,4}$/';
if (!preg_match($email_exp, $email)) {
$error_message .= 'The Email address you entered does not appear to be valid.<br>';
}
$string_exp = "/^[A-Za-z .'-] $/";
if (!preg_match($string_exp, $name)) {
$error_message .= 'The Name you entered does not appear to be valid.<br>';
}
if (strlen($message) < 2) {
$error_message .= 'The Message you entered do not appear to be valid.<br>';
}
if (strlen($error_message) > 0) {
problem($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string)
{
$bad = array("content-type", "bcc:", "to:", "cc:", "href");
return str_replace($bad, "", $string);
}
$email_message .= "Name: " . clean_string($name) . "\n";
$email\_message .= "Subject: " . clean\_string($subject) . "\\n";
$email_message .= "Email: " . clean_string($email) . "\n";
$email_message .= "Message: " . clean_string($message) . "\n";
// create email headers
$headers = 'From: ' . $email . "\r\n" .
'Reply-To: ' . $email . "\r\n" .
'X-Mailer: PHP/' . phpversion();
u/mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your success message below -->
Thank you for contacting me. I will be in touch with you very soon.
<?php
}
?>
Am editat pentru acest post functia de mail to.
Subreddit
Post Details
- Posted
- 3 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/programare/...