I have the following code in html, a simple email form:
<form class="main_form" method="post" action="sendmail.php">
<div class="row">
<div class="col-xl-12 col-lg-12 col-md-12 col-sm-12">
<input class="form-control" placeholder="title" type="text" name="Title">
</div>
<div class="col-xl-12 col-lg-12 col-md-12 col-sm-12">
<input class="form-control" placeholder="Email" type="text" name="Email">
</div>
<div class="col-xl-12 col-lg-12 col-md-12 col-sm-12">
<textarea class="textarea" placeholder="message" type="text" name="Message"></textarea>
</div>
<div class="col-xl-12 col-lg-12 col-md-12 col-sm-12">
<button class="send" >send</button>
</div>
</div>
</form>
And this is the script I want to run everytime you hit "send" (sendmail.php)
<?php
if (isset($_POST['submitted_form'])){
$subject = $_POST['Title'];
$message = "Email : $_POST['Email'] Message: $_POST['Message']";
$headers = "From:abc@xyz.com";
send_mail($subject,$message,$headers);
}
function send_mail( $subject, $message, $headers){
// https://stackoverflow.com/questions/5335273/how-can-i-send-an-email-using-php
$to = "bordadoscreativos.02@gmail.com";
if(mail($to, $subject, $message, $headers)){
echo "Message sent successfully...";
}else {
echo "Message could not be sent...";
}
}
?>
Now my problem is that everytime I hit send, the URL changes to http://127.0.0.1:8000/sendmail.php and it throws a 404. what should I do? Create a controller for sendmail.php? I already tried creating a route inside web.php for sendmail.php but it still doesn't work.