简体   繁体   中英

Have php form submit email and a text file

Hi I have a form that lately has been having some issues. The email is not always going through, have checked spam folder, that's not it.

I wanted to know how to append the process to also write to a text. Here is my form

   if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
    // if verification code was correct send the message and show this page

    $message = "Lastfour: ".$lastfour."\n".$message;
    $message = "Exchange: ".$exchange."\n".$message;
    $message = "Phone: ".$phone."\n".$message;
    $message = "bedrooms: ".$bedrooms."\n".$message;
    $message = "resortname: ".$resortname."\n".$message;
    $message = "From: ".$from."\n".$message;
    $message = "lastName: ".$lastname."\n".$message;
    $message = "Name: ".$name."\n".$message;
    mail("myeamail@mail.com", 'Online Form: '.$resortname, $_SERVER['REMOTE_ADDR']."\n\n".$message, "From: $from");
    // delete the cookie so it cannot sent again by refreshing this page
    setcookie('tntcon','');
} else {
    // if verification code was incorrect then return to contact page and show error
    header("Location:".$_SERVER['HTTP_REFERER']."?subject=$resortname&from=$from&message=$message&wrong_code=true");
    exit;
}
?>

is there a edit to this or do I need to run another process?

Thanks

To write to a text file just add this section where you want the process to be carried out

$myFile = "myFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "text I want to write in the file\n";
fwrite($fh, $stringData);
fclose($fh);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM