Go Back   Dynamic Drive Forums > General Coding > PHP
Search Dynamic Drive Forums:

Reply
 
Thread Tools Search this Thread
  #1  
Old 04-12-2007, 07:02 AM
tomyknoker tomyknoker is offline
Senior Coders
 
Join Date: Apr 2006
Posts: 586
Thanks: 0
Thanked 0 Times in 0 Posts
Default Showing Date In Email Subject

Shouldn't it be as simple as this to display the date in my email subject? When I run this it just display exactly what's written, ignores the code...

PHP Code:
$message = <<<HERE
The following people are members as of echo date('d-m-Y');.
The login information is as follows:
-----------------------------------------

$login
HERE;


$from "Email <me@mydomain.com>";

mail($to$subject$message'From: '.$from);
}

?> 
Reply With Quote
  #2  
Old 04-12-2007, 07:36 AM
djr33's Avatar
djr33 djr33 is offline
Global Moderator
 
Join Date: Mar 2006
Location: N. California, USA
Posts: 6,408
Thanks: 11
Thanked 82 Times in 82 Posts
Default

erm...
$subject = date(...);
??


As for the above, that's the body, not subject, and you're using the <<<...; method for setting a string, so it won't parse anything.

There's limited parsing with the {$var} construct, but I think that's limited to variables.

You could set
$date = date(...);
Then use {$date} in the <<<EOF thing,
or you could just split the string and output (echo) date() directly, by itself, not as part of the EOF.
__________________
Daniel - <?php?> | <html>| Ich lerne Deutsch. | Studio l'italiano. | Estudiaba español. | Estudo português. | 日本語の勉強。| मैं हिन्दी सीखो | درس العربية
Reply With Quote
  #3  
Old 04-12-2007, 01:25 PM
boogyman boogyman is offline
Elite Coders
 
Join Date: Jul 2006
Location: just north of Boston, MA
Posts: 1,789
Thanks: 12
Thanked 72 Times in 72 Posts
Default

You need to fix your mail function... highlighted at red

Code:
mail($to, $subject, $message,header('From: '.$from));
__________________

This is a forum system not a PM system for questions. please treat it appropriately
Reply With Quote
  #4  
Old 04-12-2007, 02:03 PM
djr33's Avatar
djr33 djr33 is offline
Global Moderator
 
Join Date: Mar 2006
Location: N. California, USA
Posts: 6,408
Thanks: 11
Thanked 82 Times in 82 Posts
Default

Hmm... I don't think that's the original question.
And, The headers in the mail function aren't used with the header() function, I don't believe. header(), from how I have seen it used, outputs directly, before any html in the php script, to the browser, informing it as to the type of output (like html, or javascript, or jpeg).
I might be wrong here, though, since I haven't gone too deep in the use of headers within the mail() function.
I do know, though, that just a string with the right format will work for that.
__________________
Daniel - <?php?> | <html>| Ich lerne Deutsch. | Studio l'italiano. | Estudiaba español. | Estudo português. | 日本語の勉強。| मैं हिन्दी सीखो | درس العربية
Reply With Quote
  #5  
Old 04-12-2007, 02:31 PM
mburt's Avatar
mburt mburt is offline
Elite Coders
 
Join Date: Jul 2006
Location: Canada
Posts: 2,507
Thanks: 5
Thanked 22 Times in 22 Posts
Default

It's a specific order of strings for the headers on the mail function, followed by \r\n after each one.

From php.net:
Code:
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();
But again, that wasn't the question. The OP's original question (about date(); ) was already answered.
Reply With Quote
  #6  
Old 04-16-2007, 04:28 AM
realmetrics.com realmetrics.com is offline
New Comer (less than 5 posts)
 
Join Date: Apr 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Use getdate() function to get the current date.

Code:
 

<?php
$message = “The following people are members as of echo date('d-m-Y');. 
The login information is as follows: 
-----------------------------------------“;
$subject = getdate();
$from = "Email <me@mydomain.com>"; 
mail($to, $subject, $message, 'From: '.$from); 
} 
?>
getdate() function returns an array that contains date and time information for a Unix timestamp.

I think this answers your question.

Last edited by tech_support; 04-16-2007 at 10:11 AM. Reason: Please wait until you have 5 posts before having a signature.
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 12:39 AM.

Home - Contact Us - Archives - Link to DD - Top 

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.