I was hoping someone could help me find out why my form page isn't working

Here is my code: The page opens, but when I submit it I get this message " This page isn’t working
If the problem continues, contact the site owner.
HTTP ERROR 405"

  <div class="form">
    <form action="contactform.php" method="post">
      <div class="name-section">
        <input type="text" name="name" autocomplete="off" required />
        <label for="name" class="label-name"></label>
        <span class="content-name">Name</span>
      </div>
      <div class="companyname-section">
        <input type="text" name="CompanyName" autocomplete="off" required />
        <label for="Company Name" class="label-name"></label>
        <span class="content-name">Company Name</span>
      </div>
      <div class="phonenumber-section">
        <input
          type="tel"
          name="PhoneNumber"
          autocomplete="off"
          pattern="[0-9]{3} [0-9]{3}-[0-9]{4}"
          required
        />
        <label for="Phone Number" class="label-name"></label>
        <span class="content-name">Phone Number</span><br />
      </div>
      <div class="email-section">
        <input type="email" name="email" autocomplete="off" required />
        <label for="email" class="label-name"></label>
        <span class="content-name">Email Address</span>
      </div>
      <div class="messageus">
        <label for="Message" class="label-name"></label>
        <span class="content-name">Message Us!</span>
        <br />

        <textarea
          id="sagecontact"
          name="MessageUs"
          rows="4"
          cols="50"
        ></textarea>
      </div>
      <input type="submit" value="submit" id="submitbutton">
    </form>
  </div>

Thanks for any and all help

***Edit: So my php problems are fixed but when I add my …json page and try to load my website I get this message back: Not Found

The requested resource / was not found on this server.

But when I delete my .json page my website loads

my .json page only has this
{
“install”: “echo ‘We Are Ready!’”,
“start”: “php -S 0.0.0.0:3000 -t .”
}

Can you please tell us the name of the project

Why is there no index.html

@jrstokes73 is the link below the form that is not workin?
https://sage-sourcing-and-support.glitch.me/submitinfo.html

Your project is likely not working because you are trying to POST information to a static HTML page. I recommend that read into PHP forms as PHP is a great language for managing user input such as forms.

https://www.w3schools.com/php/php_forms.asp

1 Like

I do like PHP better, but it’s not well supported on Glitch. Would recommend using Express Routing for you POST

2 Likes

Really either option works, Express docs can be found here:

https://expressjs.com/

1 Like

yes. That is the link to the form I am talking about

Is this error fixed? From looking at your source code, it looks like you have set up PHP as the POST.

To run php you need to add this to your glitch.json file @jrstokes73

{
  "install": "echo 'We Are Ready!'",
  "start": "php -S 0.0.0.0:3000 -t ."
}
1 Like

I did that, filled out my form, submitted it, and got back
" This page isn’t working

sage-sourcing-and-support.glitch.me is currently unable to handle this request.

HTTP ERROR 500"

HTTP 500 means you have a PHP error. Do you have any errors in the logs?

here’s what my php code looks like:

<?php ( isset( $_POST['submit'] ) )| $name = $_POST['name'];| $CompanyName = $_POST['CompanyName'];| $PhoneNumber = $_POST['PhoneNumber'];| $email = $_POST['email'];| $MessageUs = $_POST['MessageUs'];| ?>

Could you put it in back ticks? That makes it a lot easier to read. :slight_smile:

edited with | to seperate code

Are there any errors in the logs?

Sorry, not sure how to check those

Click on tools, the click logs.

1 Like

SyntaxError: Unexpected end of JSON input
at JSON.parse ()
at /opt/watcher/source/app-picker.ts:106:39
at ChildProcess.exithandler (child_process.js:285:7)
at ChildProcess.emit (events.js:189:13)
at ChildProcess.EventEmitter.emit (domain.js:441:20)
at maybeClose (internal/child_process.js:970:16)

[Fri Jun 5 16:18:05 2020] PHP Parse error: syntax error, unexpected ‘$name’ (T_VARIABLE) in /app/contactform.php on line 2

12:18 PM

[Fri Jun 5 16:18:05 2020] 127.0.0.1:55932 [500]: /contactform.php - syntax error, unexpected ‘$name’ (T_VARIABLE) in /app/contactform.php on line 2
at Socket.stream.socket.on (internal/child_process.js:389:11)
at Socket.emit (events.js:189:13)
at Socket.EventEmitter.emit (domain.js:441:20)
at Pipe._handle.close (net.js:597:12)