0

I'm running a php script that is supposed to send an email when the form is submitted. When I submit the form I receive the following error.

This XML file does not appear to have any style information associated with it. The document tree is shown below.
      <Error><Code>InvalidArgument</Code><Message>Invalid argument.</Message><Details>Missing file part</Details></Error>

This is my html code

<html lang="en">
<head>
    <script src="email_me.php"></script>   
    <meta charset="utf-8">
</head>

<section class="contact_us1">
    <form action="email_me.php" method="post" role="form" aria-label="contact form" enctype="multipart/form-data">
        <div>
            <input id="field1" aria-invalid="false" name="Name" value="" placeholder="Name" data-aid="nameField" type="text" required>
            <input id="field2" aria-invalid="false" name="Email" value="" placeholder="Email" data-aid="emailField" type="text" required>
            <input id="field4" aria-invalid="false" name="Subject" value="" placeholder="Subject" data-aid="subjectField" type="text">
        </div>
        <textarea name="Message" class="message" placeholder="Message" data-aid="messageField" ></textarea>
        <button type="submit" >Send</button>            
    </form>
</section>

And this is my PHP script

<?php
if($_POST["submit"]) {
    $recipient="my@email.com"; //Enter your mail address
    $subject=$_POST["Subject"]; //Subject 
    $sender=$_POST["Name"];
    $senderEmail=$_POST["Email"];
    $message=$_POST["Message"];
    $mailBody="Name: $sender\nEmail Address: $senderEmail\nSubject:$subject\n\nMessage: $message";
    mail($recipient, $subject, $mailBody);
    sleep(1);
    header("Location:http://www.affordtotrip.com/"); // Set here redirect page or destination page
}
?>

I am using google cloud as the server, for which I created a bucket. Upon submitting, I want an email to be sent and for the page to refresh.

Update

I went through the php tutorial and tried to set up a custom domain

I don't know how to link this php project to my actual html page though. The only DNS record that I had trouble with is

Custom domain name            SSL Security RecordType Data                  Alias 
Google-managed, auto-renewing -            CNAME      ghs.googlehosted.com  www 

Because it clashes with this domain

Type    Name        Data                        TTl
CNAME   www         c.storage.googleapis.com    600 sec

I receive the following error when I change my cname record to the ghs one

<Error>
<Code>InvalidArgument</Code>
<Message>Invalid argument.</Message>
<Details>The requested project was not found.</Details>
</Error>

Sorry for how confusing this edit is, I'm entirely confused as to what I've been doing with google cloud. I have a project in the storage bucket, and another project in the app engine, but I don't know how to either display my html in the app engine or how to execute my php project from my storage bucket.

Here's a picture of my DNS settings at godaddy enter image description here

A picture of my php bucket list enter image description here

A picture of the email me bucket enter image description here

And a picture of the DNS setting google cloud listed under custom web address enter image description here

Sam
  • 1,765
  • 11
  • 82
  • 176

1 Answers1

2

Your server doesn't allow PHP scripts to be executed and renders it seemingly just a text. Check with your server provider how to fix this.

Karlo Kokkak
  • 3,674
  • 4
  • 18
  • 33
  • The server is a bucket in google cloud. Would you be able to recommend something other than google cloud or something other than php for this? I want to do something server end because I know I'm going to have to execute stuff on the server in the future anyway. – Sam Mar 30 '18 at 06:43
  • 3
    Google Cloud Storage can host **static** files, it won't execute the .php files. You might want to see https://cloud.google.com/php/ for PHP hosting options in Google Cloud Platform – Matt-y-er Mar 30 '18 at 07:21
  • @Matt-y-er I posted an edit, I tried to explain it the best I could but I'm really confused as to what is necessary information and what isn't, all I really know is that I can't get the webpage working. – Sam Apr 03 '18 at 04:51