I have a form that sends information to an email via a php file.
My HTML form is as below:
<form method="post" action="start-project.php">
<fieldset>
<span><input type="text" name="name" id="name" placeholder="Your Name" required/></span>
<span><input type="email" name="email" id="email" placeholder="Email Address" required/></span>
<span><input type="text" name="phone" id="phone" placeholder="Phone Number" required/></span>
<span><input type="text" name="website" id="website" placeholder="Website (Optional)" /></span>
</fieldset>
<span><input type="submit" name="submit" value="GET STARTED"></span>
</form>
and my php code is as below:
<?php
$EmailFrom = "email@domain.com";
$EmailTo = "receiver@email.com";
$Subject = "Submission: Start a Project";
$name = Trim(stripslashes($_POST['name']));
$phone = Trim(stripslashes($_POST['phone']));
$email = Trim(stripslashes($_POST['email']));
$website = Trim(stripslashes($_POST['website']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $name;
$Body .= "
";
$Body .= "Tel: ";
$Body .= $phone;
$Body .= "
";
$Body .= "Email: ";
$Body .= $email;
$Body .= "
";
$Body .= "Website: ";
$Body .= $website;
$Body .= "
";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=sent.php\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
How can I have the entry data to be save in a text file on the server? I have seen few articles but I don't know how to implement it with my code.
I appreciate any help.