extracting a array and using it as a variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
MeHigh
Forum Newbie
Posts: 13
Joined: Mon Jun 30, 2003 9:31 am

extracting a array and using it as a variable

Post by MeHigh »

Please....Help!

I have the folowing problem:
I have this form that uses arrays to store data from users.
Now, I am supposed to make this form send a thank you mail with the mail the user entered.
I've found the function that can send this mail and it's something like this:

Code: Select all

$tomail = $_REQUESTї'fieldsїemail]їro]']; 
$frommail = "me@host.ro"; 
$subject = "Example message"; 
$content = "The message"; 
$header = "From: $frommail\r\n" ."Reply-To: $frommail\r\n"; 
$sendmail = mail("$tomail","$subject","$content", "$header");
and here is the code that stores the arrays(it's preety big so I'll use just the part that contains the mail field)

Code: Select all

$fields=array();

$fieldsї'first name']ї'ro']='Prenume';
$fieldsї'first name']ї'en']='First name';

$fieldsї'last name']ї'ro']='Nume';
$fieldsї'last name']ї'en']='Last name';

$fieldsї'address']ї'ro']='Adresa';
$fieldsї'address']ї'en']='Address';

$fieldsї'birthdate']ї'ro']='Data naºterii';
$fieldsї'birthdate']ї'en']='Birthdate';

$fieldsї'day']ї'ro']='Zi';
$fieldsї'day']ї'en']='Day';

$fieldsї'month']ї'ro']='Luna';
$fieldsї'month']ї'en']='Month';

$fieldsї'year']ї'ro']='An';
$fieldsї'year']ї'en']='Year';

$fieldsї'employed']ї'ro']='Angajat';
$fieldsї'employed']ї'en']='Employed';

$fieldsї'employer']ї'ro']='Firma la care lucraþi';
$fieldsї'employer']ї'en']='Your employer';

$fieldsї'phone']ї'ro']='Telefon fix';
$fieldsї'phone']ї'en']='Phone';

$fieldsї'mobile']ї'ro']='Telefon mobil';
$fieldsї'mobile']ї'en']='Mobile phone';

$fieldsї'email']ї'ro']='Adresa e-mail';
$fieldsї'email']ї'en']='E-mail address';

$fieldsї'website']ї'ro']='Pagina web';
$fieldsї'website']ї'en']='Website';

$fieldsї'studies']ї'ro']='Studii';
$fieldsї'studies']ї'en']='Studies';
Also...

The form uses an outside .php file to store the data in a data base.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What exactly do you need help with?

Mac
User avatar
MeHigh
Forum Newbie
Posts: 13
Joined: Mon Jun 30, 2003 9:31 am

Post by MeHigh »

I need help with using the e-mail the user fills - this array:

Code: Select all

$fieldsї'email']ї'ro']='Adresa e-mail'; 
$fieldsї'email']ї'en']='E-mail address';
...because the part

Code: Select all

$tomail = $_REQUESTї'fieldsїemail]їro]'];
doesn't seem to be working.
qartis
Forum Contributor
Posts: 271
Joined: Sat Dec 14, 2002 4:43 pm
Location: BC, Canada
Contact:

Post by qartis »

Try

Code: Select all

$tomail = $_REQUEST[$fields['email']['ro']];
User avatar
MeHigh
Forum Newbie
Posts: 13
Joined: Mon Jun 30, 2003 9:31 am

Post by MeHigh »

It's not working .
It tells me "Undefined variable: fields".

The script has no actual function.
It calls an outside source where all the functions are stored.
I will try to work it in that file.
qartis
Forum Contributor
Posts: 271
Joined: Sat Dec 14, 2002 4:43 pm
Location: BC, Canada
Contact:

Post by qartis »

After all of that

Code: Select all

$fieldsї'email']ї'ro']='Adresa e-mail';
$fieldsї'email']ї'en']='E-mail address';

$fieldsї'website']ї'ro']='Pagina web';
$fieldsї'website']ї'en']='Website';

$fieldsї'studies']ї'ro']='Studii';
$fieldsї'studies']ї'en']='Studies';

stuff, $feilds still isn't set? Or does the error "Undefined Variable" occur in code that's executed inside of a function?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Why are you using $_REQUEST? Is this array being sent through a form or something?

Mac
User avatar
MeHigh
Forum Newbie
Posts: 13
Joined: Mon Jun 30, 2003 9:31 am

Post by MeHigh »

yes, it's sent through this form
http://www.gecad.ro/page_career_cv.php

It takes the values the user entered and sends it to a database .
User avatar
MeHigh
Forum Newbie
Posts: 13
Joined: Mon Jun 30, 2003 9:31 am

Post by MeHigh »

qartis wrote:After all of that

Code: Select all

$fieldsї'email']ї'ro']='Adresa e-mail';
$fieldsї'email']ї'en']='E-mail address';

$fieldsї'website']ї'ro']='Pagina web';
$fieldsї'website']ї'en']='Website';

$fieldsї'studies']ї'ro']='Studii';
$fieldsї'studies']ї'en']='Studies';

stuff, $feilds still isn't set? Or does the error "Undefined Variable" occur in code that's executed inside of a function?

well i tried to use the mail() function like this:

Code: Select all

mail(
$HTTP_POST_VARSї$email],
"the title",
"the message",
"MIME-Version: 1.0\r\nContent-type: text/html;\r\nFrom:ceva@gecad.ro");
and it gave me this "undefined error" message

than I tried it like this:

Code: Select all

function autorespond()
{
$ToMail = $_REQUESTї$fieldsї'email']ї'ro']];
$FromMail = "mdragan@gecad.ro"; 
$Subject = "Example message"; 
$Content = "This is the content of the message\n\nGreetz Jolly"; 
$Header =     "From: $FromMail\r\n" ."Reply-To: $FromMail\r\n"; 
$Sendmail = mail("$ToMail","$Subject","$Content", "$Header"); 
}
and it shows nothing now

I'm Confused :?
Post Reply