Forum Articles
  Welcome back Join CF
You are here You are here: Home | Forum | Aaarrrrrrrggggghh Spammers

You are currently viewing our boards as a guest which gives you limited access to view most of the discussions, articles and other free features. By joining our Virgin Media community you will have full access to all discussions, be able to view and post threads, communicate privately with other members (PM), respond to polls, upload your own images/photos, and access many other special features. Registration is fast, simple and absolutely free so please join our community today.


Welcome to Cable Forum
Go Back   Cable Forum > Computers & IT > Internet Discussion
Register FAQ Community Calendar

Automatic mail on PHP web page?
Reply
 
Thread Tools
Old 23-06-2009, 15:10   #1
Walford
Inactive
 
Join Date: Apr 2009
Location: Bristol
Services: 10MB Broadband from VM
Posts: 110
Walford is on a distinguished roadWalford is on a distinguished road
Automatic mail on PHP web page?

Is there anyway I can be emailed automatically when someone accesses a certain web page scripted in PHP? I don't know much PHP so I am looking really for someone to find my a code which does this?
Walford is offline   Reply With Quote
Advertisement
Old 26-06-2009, 12:59   #2
funkyCable
Inactive
 
Join Date: Aug 2005
Location: Canvey Island, Essex
Services: SERVICES FROM 26/08/05 TV XL services 2MB BROADBRAND UNLIMITED TALK PACKAGE V+ Service (Since 18
Posts: 1,195
funkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nice
Re: Automatic mail on PHP web page?

should be fairly easy to send an email as soon as someone accesses a php page. You would need to write a session cookie to store a value to avoid getting multiple emails eg if a user refreshes/submits the page this would coarse the page to send another email which you may not want

Does your web pages use any authentication? Could I ask what you need this for? Do you have a it connected to a database such as mysql? If so you could record it there rather than emails.
funkyCable is offline   Reply With Quote
Old 26-06-2009, 13:48   #3
Keyz333
Inactive
 
Join Date: Oct 2007
Location: Fleet, Hampshire
Age: 35
Services: Cuckoo (BT) Broadband
Posts: 265
Keyz333 has a spectacular aura about themKeyz333 has a spectacular aura about themKeyz333 has a spectacular aura about themKeyz333 has a spectacular aura about them
Send a message via AIM to Keyz333 Send a message via MSN to Keyz333
Re: Automatic mail on PHP web page?

Do you need the email to say WHO visited the page?
Or just that someone has?
Keyz333 is offline   Reply With Quote
Old 26-06-2009, 14:03   #4
Walford
Inactive
 
Join Date: Apr 2009
Location: Bristol
Services: 10MB Broadband from VM
Posts: 110
Walford is on a distinguished roadWalford is on a distinguished road
Re: Automatic mail on PHP web page?

Quote:
Originally Posted by Keyz333 View Post
Do you need the email to say WHO visited the page?
Or just that someone has?
Just to say someone has visited and thats it.

Can anyone help?
Walford is offline   Reply With Quote
Old 26-06-2009, 14:21   #5
Keyz333
Inactive
 
Join Date: Oct 2007
Location: Fleet, Hampshire
Age: 35
Services: Cuckoo (BT) Broadband
Posts: 265
Keyz333 has a spectacular aura about themKeyz333 has a spectacular aura about themKeyz333 has a spectacular aura about themKeyz333 has a spectacular aura about them
Send a message via AIM to Keyz333 Send a message via MSN to Keyz333
Re: Automatic mail on PHP web page?

Yeah, I'm sure I can find one for you, I'll send it over in a few minutes, when I find it

EDIT:

PHP Code:
<?php
$to 
"Your@Emailhere.com";
$subject "The Subject";
$body "EG - Someone has Visited Your Website";
if (
mail($to$subject$body)) {
  echo(
"<p>Message successfully sent!</p>");
 } else {
  echo(
"<p>Message delivery failed...</p>");
 }
?>
If you add something like that into the PHP page, it should email you, everytime someone visits that certain PHP page.

Obviously if you fill it all in first.
Keyz333 is offline   Reply With Quote
Old 26-06-2009, 14:27   #6
Cobbydaler
Inactive
 
Cobbydaler's Avatar
 
Join Date: Apr 2006
Location: Manchester, UK
Services: ClearFibre Internet, Vodafone mobile Google Pixel 4
Posts: 9,699
Cobbydaler is seeing silvered starsCobbydaler is seeing silvered starsCobbydaler is seeing silvered starsCobbydaler is seeing silvered stars
Cobbydaler is seeing silvered starsCobbydaler is seeing silvered starsCobbydaler is seeing silvered starsCobbydaler is seeing silvered starsCobbydaler is seeing silvered starsCobbydaler is seeing silvered starsCobbydaler is seeing silvered starsCobbydaler is seeing silvered starsCobbydaler is seeing silvered starsCobbydaler is seeing silvered starsCobbydaler is seeing silvered starsCobbydaler is seeing silvered starsCobbydaler is seeing silvered starsCobbydaler is seeing silvered starsCobbydaler is seeing silvered stars
Re: Automatic mail on PHP web page?

This is a simple php mail() function script

Code:
<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
I guess you just stick it in as a script that runs when the page is visited. Not sure about the session cookie thing though...
Cobbydaler is offline   Reply With Quote
Old 26-06-2009, 14:32   #7
Keyz333
Inactive
 
Join Date: Oct 2007
Location: Fleet, Hampshire
Age: 35
Services: Cuckoo (BT) Broadband
Posts: 265
Keyz333 has a spectacular aura about themKeyz333 has a spectacular aura about themKeyz333 has a spectacular aura about themKeyz333 has a spectacular aura about them
Send a message via AIM to Keyz333 Send a message via MSN to Keyz333
Re: Automatic mail on PHP web page?

It depends what kind of Page it is, if its one, where the same visitor would visit it multiple times, then you would be getting quite a few emails from the same user.

But if the user would only visit this page once, one of these 2 scripts would be fine
Keyz333 is offline   Reply With Quote
Old 26-06-2009, 15:40   #8
Walford
Inactive
 
Join Date: Apr 2009
Location: Bristol
Services: 10MB Broadband from VM
Posts: 110
Walford is on a distinguished roadWalford is on a distinguished road
Re: Automatic mail on PHP web page?

Quote:
Originally Posted by Cobbydaler View Post
This is a simple php mail() function script

Code:
<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
I guess you just stick it in as a script that runs when the page is visited. Not sure about the session cookie thing though...

Thanks. I have used this one as it gives the option of a 'from' address.

Thanks for all your help though.

Jack :-)
Walford is offline   Reply With Quote
Old 26-06-2009, 15:41   #9
Graham M
-
 
Graham M's Avatar
 
Join Date: Jul 2003
Location: Poole, Dorset
Age: 40
Services: FreeSat+ Tivo V-Box VM 60MBit
Posts: 13,365
Graham M has a pair of shiny starsGraham M has a pair of shiny stars
Graham M has a pair of shiny starsGraham M has a pair of shiny starsGraham M has a pair of shiny starsGraham M has a pair of shiny starsGraham M has a pair of shiny starsGraham M has a pair of shiny starsGraham M has a pair of shiny starsGraham M has a pair of shiny stars
Send a message via MSN to Graham M Send a message via Yahoo to Graham M
Re: Automatic mail on PHP web page?

The previous script is actually better as it checks to see if the email was sent sucessfully rather than just assuming it was, you could easily merge the 2
Graham M is offline   Reply With Quote
Old 26-06-2009, 22:29   #10
Keyz333
Inactive
 
Join Date: Oct 2007
Location: Fleet, Hampshire
Age: 35
Services: Cuckoo (BT) Broadband
Posts: 265
Keyz333 has a spectacular aura about themKeyz333 has a spectacular aura about themKeyz333 has a spectacular aura about themKeyz333 has a spectacular aura about them
Send a message via AIM to Keyz333 Send a message via MSN to Keyz333
Re: Automatic mail on PHP web page?

Something like this should suit your needs, It has the From Function & checks to see if it sends or not.

PHP Code:
<?php
$to 
"Your@Emailhere.com";
$subject "The Subject";
$body "EG - Someone has Visited Your Website";
$from "someonelse@example.com";
$headers "From: $from";
if (
mail($to$subject$body$headers)) {
  echo(
"<p>Message successfully sent!</p>");
 } else {
  echo(
"<p>Message delivery failed...</p>");
 }
?>
Keyz333 is offline   Reply With Quote
Old 26-06-2009, 23:05   #11
Graham M
-
 
Graham M's Avatar
 
Join Date: Jul 2003
Location: Poole, Dorset
Age: 40
Services: FreeSat+ Tivo V-Box VM 60MBit
Posts: 13,365
Graham M has a pair of shiny starsGraham M has a pair of shiny stars
Graham M has a pair of shiny starsGraham M has a pair of shiny starsGraham M has a pair of shiny starsGraham M has a pair of shiny starsGraham M has a pair of shiny starsGraham M has a pair of shiny starsGraham M has a pair of shiny starsGraham M has a pair of shiny stars
Send a message via MSN to Graham M Send a message via Yahoo to Graham M
Re: Automatic mail on PHP web page?

Yeah sorry I couldve done that been busy lol
Graham M is offline   Reply With Quote
Old 27-06-2009, 00:25   #12
Keyz333
Inactive
 
Join Date: Oct 2007
Location: Fleet, Hampshire
Age: 35
Services: Cuckoo (BT) Broadband
Posts: 265
Keyz333 has a spectacular aura about themKeyz333 has a spectacular aura about themKeyz333 has a spectacular aura about themKeyz333 has a spectacular aura about them
Send a message via AIM to Keyz333 Send a message via MSN to Keyz333
Re: Automatic mail on PHP web page?

Haha, Thought I'd be helpful
Keyz333 is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 00:33.


Server: lithium.zmnt.uk
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
All Posts and Content are © Cable Forum