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 24th, 2003, 10:13 AM
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 Associative Array With Text Input Boxes?

Hey Folks;

The two scripts below are for sending user input via PHP's mail() function. The scripts work fine.

For example, if I input the first name "John" in the in the textbox "First Name<input type=text name=Textfield" . "[FirstName]" . "size=15 maxlength=25>\n"; below the program below outputs and e-mails the name "John" - exactly as needed.

But here's the problem: How do I get the program below to label the "FirstName" name as follows: "The First Name Is: John"?

I guess what I need is an associative array or something where the phrase "The First Name Is" is associated with the text input box "First Name<input type=text name=Textfield" . "[FirstName]" . "size=15 maxlength=25>\n";.

Please note: I'm also wanting to store the text input data into a MySQL database so the programming would need to separate the "The First Name Is:" phrase from the text input.


PHP Code:
//---------------- TextInput.php -----------------------
<?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=hidden name=About value='Request For Life Insurance Quote'>Text Field Two<p>\n";
print 
"First Name<input type=text name=Textfield" "[FirstName]" "size=15 maxlength=25>\n";
print 
"Middle</td><td><input type=text name=Textfield" "[Middle]" "size=8 maxlength=15>\n";
print 
"Last Name</td><td><input type=text name=Textfield" "[LastName]" "size=15 maxlength=25>\n";
print 
"<input type=submit value='Click Here'></form><p>\n";
print 
"</body>\n";
print 
"</html>\n";
?>


//-------------------- WorkMail.php -------------
<?php
print ("<html>\n");
print (
"<body leftmargin=150 topmargin=150>\n");
if ( isset(
$Email) ){
$UserInput '' ;
foreach( 
$_POST['Textfield'] as $Item )
{
    
$UserInput .= '<P>' $Item '</P>' ;
}
$Data $UserInput;
$Variable1 $Email;
$Variable2 $About;
$Variable3 $Data;
//-- Mail Function: mail($To, $Subject, $Message)
class MailClass
{
    var 
$To "Email";
    var 
$Subject "About";
    var 
$Message "Data";
    function 
SetAddress1($Email)//This function tells which e-mail address will be used.
    
{
        
$this->To $Email;
    }
    function 
SetAddress2($About)//This function gives the subject message.
    
{
        
$this->Subject $About;
    }
    function 
SetAddress3($Data)//This function incorporates all of the data.
    
{
        
$this->Message $Data;
    }        
    function 
SendMail()
    {
    print 
"The address is: $this->To";
    print 
"The request is as follows: $this->Subject";
    print 
"The prospective customer information is: $this->Message";
    
mail($this->To$this->Subject$this->Message"MIME-Version: 1.0\nContent-Type: text/html; charset=iso-8859-1\n");
    
//mail($Email, $Subject, $Content, "From:admin@somat.com\nMIME-Version: 1.0\nContent-Type: text/html; charset=iso-8859-1\n");
    
}
}

$Object1 = new MailClass();//instantiates the class.
$Object1->SetAddress1("$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.";
}
print (
"</body>\n");
print (
"</html>\n");    
?> 


Thanking you in advance.

H. Pete Norris
ref. "Volitics"

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > How Do I Use Associative Array With Text Input Boxes?


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 6 hosted by Hostway
Stay green...Green IT