General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 17th, 2003, 06:42 PM
Volitics Volitics is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Knoxville, Tennessee (U.S.A.)
Posts: 58 Volitics User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 15 sec
Reputation Power: 6
How Do I Use mail($To, $Subject, $Message) Function Inside Class?

How Do I Use mail($To, $Subject, $Message) Function Inside Class?


Folks;

Below is a class that I am working on. The html form on Page One below outputs the $Email, $About, and $Data variables. The class script on Page Two processes the input information.

At the present time the script on Page Two processes the $Email, $About, and $Data input variables and assigns the values to $Variable1, $Variable2, and $Variable3, respectively. The values are then passed to the "SetAddress", "SetAddress2", and "SetAddress3" functions. And finally, the values are output in the browser window via the SendMail() function with the "$this->To", "$this->Subject", and "$this->Message" snippets as shown below.

But the functionality stops there. I need to go one step further and input the "$this->To", "$this->Subject", and "$this->Message" values into the mail($To, $Subject, $Message) function. I've tried using the following: mail($this->To, $this->Subject, $this->Message) but it won't work.


PHP Code:
//------------- Page One - Text Input Form -------
<?php
print "<html>\n";
print 
"<body leftmargin=200 topmargin=100>\n";
print 
"<form action=WorkMail.php method=post>\n";
print 
"<input type=text name=Email size=15 maxlength=25>Text Field One<p>\n";
print 
"<input type=text name=About size=15 maxlength=25>Text Field Two<p>\n";
print 
"<input type=text name=Data size=15 maxlength=25>Text Field Three<p>\n";
print 
"<input type=hidden name=TextField>\n";
print 
"<input type=submit value='Click Here'></form><p>\n";
print 
"</body>\n";
print 
"</html>\n";
?>


//------------- Page Two - entitled "WorkMail.php" ---


<?php
if ( isset($TextField) ){
//---------------------------
$Variable1 $Email;
$Variable2 $About;
$Variable3 $Data;
//-- Mail Function: mail($To, $Subject, $Message)
class MailClass
{
    var 
$To;
    var 
$Subject;
    var 
$Message;
    function 
SetAddress($Address)//This function tells which e-mail address will be used.
    
{
        
$this->To $Address;
    }
    function 
SetAddress2($Second)//This function tells which e-mail address will be used.
    
{
        
$this->Subject $Second;
    }
    function 
SetAddress3($Description)//This function tells which e-mail address will be used.
    
{
        
$this->Message $Description;
    }        
    function 
SendMail()
    {
    print 
"The address is: $this->To";//Works ok here.
    
print "The request is as follows: $this->Subject";//Works ok here.
    
print "The prospective customer information is: $this->Message";//Works ok here.
    //mail($To, $Subject, $Message) --Need to input variables here so sendmail will work.
    
}
}

$Object1 = new MailClass();//instantiates the class.
$Object1->SetAddress("$Variable1");//sets the "SetAddress" function to $Email.
$Object1->SetAddress2("$Variable2");//sets the "SetAddress2" function to $About.
$Object1->SetAddress3("$Variable3");//sets the "SetAddress3" function to $Data".
$Object1->SendMail();//Outputs the "SendMail()" function.
}else{
print 
"Didn't work. Try again.";
}
?> 


I would appreciate any suggestions. Thank you in advance.

Reply With Quote
  #2  
Old April 17th, 2003, 09:34 PM
Volitics Volitics is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Knoxville, Tennessee (U.S.A.)
Posts: 58 Volitics User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 15 sec
Reputation Power: 6
Scratch The Above

I've figured it out. The function mail($this->To, $this->Subject, $this->Message) does indeed work with the above code. The reason that I could not get it to work was because I forgot to put the semicolon ";" at the end of the function.

In order to get the above scripting to work the mail function should have the semicolon like so:
mail($this->To, $this->Subject, $this->Message);

Sorry if I caused anybody any difficulty.

If anyone can see a better way of writing the above code please feel free to post a reply.

Reply With Quote
  #3  
Old April 18th, 2003, 12:33 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
heh, semi-colon's will get ya every time...

Reply With Quote
  #4  
Old April 20th, 2003, 12:22 PM
kimy_cool kimy_cool is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 6 kimy_cool User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi,

maybe you can try out this mime class maybe it will give you an idea.

Hope it'll help.

Reply With Quote
  #5  
Old April 20th, 2003, 05:32 PM
Volitics Volitics is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Knoxville, Tennessee (U.S.A.)
Posts: 58 Volitics User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 15 sec
Reputation Power: 6
kimy_cool;

Thank you for your kind help.

I'll study over the information at the phpguru.org link. It looks like that there are some good things there.

Thanks again.

Best Regards;

Volitics

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > How Do I Use mail($To, $Subject, $Message) Function Inside Class?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT