Can i send text from a php file into a variable in an html file? I have an if statement in my php, that checks if a field is empty. If it is empty then i want to send to my html file a text saying ‘please fill the field’ and put it in a label in my html. Is there a way for that?
<?php
$name = $_REQUEST['author'];
$from = $_REQUEST['email'];
$subj = $_REQUEST['sub'];
$message = $_REQUEST['msg'];
$subject = $subj;
$body = $message;
$headers .= "From: ".$from;
$to = "mail@mail.com";
if ($name = ''){
HERE i want to send a text to a variable named 'reason' in my html in case $name is empty.
}
if(mail($to,$subject,$body,$headers)) {
header( "Location: http://www.mysite.com/contactForm-english" );
} else {
echo "There was a problem sending the mail. Check your code and make sure that the e-mail address ".$to." is valid";
}
?>
1 Answer