html – Error Missing file part Php Google cloud platform POST-ThrowExceptions

Exception or error:

I’m simply trying to “post” text from a subscribe form to a simple email php file but Google Cloud gives this error:

<Error>
<Code>InvalidArgument</Code>
<Message>Invalid argument.</Message>
<Details>Missing file part</Details>
</Error>

I have tried a few things including writing directly to the bucket in Google Cloud but I would rather have text emailed to an address. Why is there a missing file part?

here is my form code:

<form action="email.php" method="post" enctype="multipart/form-data">
<input type="text" name="email" size="15" style="font-size:29px;" id="email" required placeholder="Email">
<input value="RSVP" class="button" name="button" style="font-size:29px;" type="submit">
</form>

Here is my php file:

<?php

$to = "email@gmail.com"; // 
$from = "no-reply@website.com"; // 

$headers = "From: " . $from . "rn";

$subject = "New subscription";
$body = "New user subscription: " . $_POST['email'];
if( filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) )
{
if (mail($to, $subject, $body, $headers, "-f " . $from))
{
echo 'Your e-mail (' . $_POST['echo $this->mail'] . ') has been added to our mailing list!';
}
else
{
echo 'There was a problem with your e-mail (' . $_POST['email'] . ')';
}
}
?>
How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *