Inserting PHP Code into a web page

User 2778933 Photo


Registered User
16 posts

Hello there!

I would like to insert the following PHP code into a web page.
It sends me an email every time someone opens the web page.
Could someone explain how to do this?

Thank you!!

THE PHP CODE:

<?php
pSendEmail () ;

//******** FUNCTIONS ***************
Function pSendEmail ()
{

//$pos = strpos($Email, "@");
//$Email = mb_substr($Email, 0, ($pos-1));
$title = "HseMgr PH: Tenants-Current-View.php just Opened";
$message = "This page is open to Administrator and House Helper/Manager
\n\n";


mail("home@proctor-place.com", $title, $message, "From: PH <home@proctor-place.com>\nReply-To: home@proctor-place.com");
}

?>

User 187934 Photo


Senior Advisor
20,192 posts

Hi Andrea,
First is your site hosted on Coffeecup? If so you won't be able to do any php coding.
If it's on a different host then there are a couple of ways to do this.
One way is to export your project and insert the code into the page with a html editor.
You may need to change the page name extension to .php if your host isn't setup to parse php within HTML.
The other way is to setup your host to parse php inside html pages. This will allow you to leave the page names as is. To parse php inside html pages you need to add a line of code to your .htaccess file on your host.
AddType application/x-httpd-php .php .html

Either way you can insert the code into a html element before export if you want but it won't work until you upload the site.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.