Page 1 of 1

extracting a array and using it as a variable

Posted: Mon Jun 30, 2003 9:31 am
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.

Posted: Mon Jun 30, 2003 9:32 am
by twigletmac
What exactly do you need help with?

Mac

Posted: Mon Jun 30, 2003 10:18 am
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.

Posted: Mon Jun 30, 2003 1:05 pm
by qartis
Try

Code: Select all

$tomail = $_REQUEST[$fields['email']['ro']];

Posted: Tue Jul 01, 2003 1:56 am
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.

Posted: Tue Jul 01, 2003 2:21 am
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?

Posted: Tue Jul 01, 2003 3:30 am
by twigletmac
Why are you using $_REQUEST? Is this array being sent through a form or something?

Mac

Posted: Tue Jul 01, 2003 3:40 am
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 .

Posted: Tue Jul 01, 2003 3:48 am
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 :?