PDA

View Full Version : mail() register globals off problem :(


PHPlearner
07-12-2004, 12:39 AM
Hey all you smart people , i've been looking everywhere for my problem , but haven't found a solution yet , so i hope you can help me out here ....

My host have register globals turned off , so i can't get the mail() function to work :(

On my host's website , it is stated that i can open a connection to their internal smtp server , but it doesn't say how , and im still in the learning process of php.

Can someone please help me out with getting the mail() to work with or without the smtp connection , i don't really care , as long as it will work .

Thanks in advance

PHPlearner
07-12-2004, 05:05 AM
Anyone ? :(

freddycodes
07-12-2004, 05:26 AM
The only register_globals will affect is how you access incoming data.

Instead of accessing variables in their global state you will need to go through the appropriate input arrays.

So instead of things like $name and $email it would be $_POST['name'] or $_GET['name']

PHPlearner
07-12-2004, 06:08 AM
Thanks for answering that Freddy , but whats wrong with this script then ?


<?php

$toEmail = $_POST['[email protected]'];
$subject = $_POST['subject'];
$message = $_POST['message'];

$from = $_POST['email'];

mail($toEmail, $subject, $message, $from);


?>


Im going crazy over this :(

freddycodes
07-12-2004, 03:43 PM
this line.

$toEmail = $_POST['[email protected]'];


[email protected] is not a valid property name, what was the variable name. You are only assigning this value in php right, its not coming from flash?


$toEmail = "[email protected]";



Also

mail($toEmail, $subject, $message, $from);


the fourth param to the mail call is the header param
It needs to be formatted correctly. A simple email address is not enough, and where does $from get populated from?

PHPlearner
07-13-2004, 06:40 AM
Hey Freddy , yes im only assigning that value in php and not in Flash .

Can you please define why the " A simple email address is not enough " isn't enough ? :confused:

Also if i would like to include the users , ip , browser info , in the mail im recieving , how would i add that to the header ? PHP is confusing :(

CyanBlue
07-13-2004, 12:41 PM
What he is saying is that you are not using the mail() function correctly...

Open up the PHP manaul and look for mail() function to see how you can use header stuff... PHP manual is mighty handy and it's got lots of code snippets... :)

PHPlearner
07-14-2004, 03:52 PM
Yeah thanks guys , i got it working :)