I need help with php for my page

Hello, I want to implement php to my web page so that users can leave their email. I reused an internet code but it doesn’t work. Could you please help me. This is the url of the project: https://glitch.com/~guazuvira

First off, your project needs a special file called glitch.json to run PHP. Add a file called glitch.json and add this code to it:

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

Second, I see you are trying to use the PHP mail() function. To use this, you either need your own mail server or you need to change the php.ini file, which you need the lamp-poc glitch project to do. (Also, PHP’s mail function isn’t super great).

If you use the chat app Discord, you can use Discord webhooks to receive messages. You can learn more about webhooks here and get some sample code here.

Also, just a side note, if you are creating a redirect with php headers, you should at die() to the bottom to kill the program to ensure a redirect.

Your Code:
header("Location:index.html");

Corrected:

header("Location: index.html);
die();

Good luck!

1 Like

Thank you so much, just one more question: how do I change the php.ini file and how do I implement the lamp-poc glitch project in my project?

The lamp-poc project is an Apache webserver on Glitch. You can remix it and add your files to it by clicking here:

1 Like

Hello again and sorry for bothering you, I already remixed the lamp-poc project and added my files, but when I test the page, the email I enter never arrives. What do I have to do to send it to me? This is the new url: https://glitch.com/~fate-amber-dessert

You will need to define the mail server in the php.ini file.

But don’t 100% reccomend doing this:

Discord is much easier.

1 Like