help with classified site script

Discussion in 'PHP' started by primster7, Jun 5, 2008.

  1. #1
    Hello,

    I have a classified ad script and just want it to email me once someone has posted an ad. Can someone give me some code that I can add to the php file?

    Any help would be appreciated.


    Thanks!
     
    primster7, Jun 5, 2008 IP
  2. Christian Little

    Christian Little Peon

    Messages:
    1,753
    Likes Received:
    80
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    function signup_notification() {
    	$to      = 'you@example.com';
    	$subject = 'New User Signup Notification';
    	$message = 'This is the body of the notification email.  You can include things like $username signed up!';
    	$headers = 'From: you@example.com' . "\r\n" .
    		'Reply-To: roreply@example.com' . "\r\n" .
    		'X-Mailer: PHP/' . phpversion();
    	mail($to, $subject, $message, $headers);
    }
    
    PHP:
    Put that into a seperate file called signupemail.php or something like that.

    Change the content (i.e. email address it sends to, and the message it sends).

    Then add the following code to your existing code so it executes right after a signup occurs:

    
    	include("path_to_new_code/signupemail.php");
    	signup_notification();
    
    PHP:
     
    Christian Little, Jun 5, 2008 IP
  3. primster7

    primster7 Well-Known Member

    Messages:
    801
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    110
    #3
    Thanks for the response Christian Little, but I'm getting this error.

    , Fatal error: Call to undefined function signup_notification() in /path blanked out for obvious reason.
     
    primster7, Jun 5, 2008 IP
  4. Christian Little

    Christian Little Peon

    Messages:
    1,753
    Likes Received:
    80
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Did you wrap the function with <? and ?>
     
    Christian Little, Jun 5, 2008 IP
  5. primster7

    primster7 Well-Known Member

    Messages:
    801
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    110
    #5

    Thanks a lot.. I forgot to add that.

    It works fine now.

    Rep added.
     
    primster7, Jun 5, 2008 IP