HELP! with PHP please?

Sup everyone-

Could you guys look at my scripts and tell me what the heck am I doing wrong? I can’t get this PHP thing to work at all. I’m not getting any emails sent. I’ve looked over and searched my brains out on PHP, and still no luck for two days now. Help me please? I’m still a newbie at this thing.

My form is a flash form.

php script saved as a php3 file:


<?

$email_subject = '[E-mail Application]';
$email_to = '[email protected]';
$email_from_name = 'customername';
$email_from = 'customeremail';
$email_header = 'customerphone';
$email_footer = 'customercomment';
$email_redirect = '';

$valid_referer = array(
        'charlotteshouses.com'
);

$is_good = false;
while(list($junk, $site) = each($valid_referer)) {
        if (eregi($site.'/', $_SERVER['HTTP_REFERER'])) {
                $is_good = true;
                break;
        }
}

if (!$is_good) {
        echo "Error. Invalid referrer: '".$_SERVER['HTTP_REFERER']."'";
        exit;
}

while(list($n, $v) = each($_POST)) {
        switch(strtoupper($n)) {
//              case 'TO':
//                      $email_to = $v;
//                      break;
                case 'FROM':
                        $email_from = $v;
                        break;
                case 'SUBJECT':
                        $email_subject = $v;
                        break;
                case 'FROM_NAME':
                        $email_from_name = $v;
                        break;
                case 'HEADER':
                        $email_header = $v;
                        break;
                case 'FOOTER':
                        $email_footer = $v;
                        break;
                case 'REDIRECT':
                        $email_redirect = $v;
                        break;
                case 'SIGNATURE':
                        break;
                case 'SUBMIT':
                        break;
                default:
                        $email_body .= $n.' => '.$v."
";
                        break;
        }
}

if ($email_header)
        $email_body = $email_header."
".$email_body;

if ($email_footer)
        $email_body = $email_body."
".$email_footer;


mail($email_to, $email_subject,
        $email_body,
         "From: \"".$email_from_name."\" <".$email_from.">
"
        ."Reply-To: \"".$email_from_name."\" <".$email_from.">
"
        .'X-Mailer: RackNine_Mail_Program/' . phpversion());

if ($email_redirect) {
        header("Location: ".$email_redirect);
        exit();
}
?>

What is your Flash code?

Check this thread:

http://64.207.155.38/forums/showthread.php?s=&threadid=15399&highlight=%24POST

Because PHP by default has global variables turned off, you need to use the POST, or GET array to grab the variables from the previous page. Flash is no exception. If you do what i did in the other thread that you posted:

http://64.207.155.38/forums/showthread.php?s=&threadid=16983

you should be all set.

Also, where did you get that code from? That could help also… but try to POST/GET array and you should get some results.

thanks jubba. i’ll keep you posted…matter of fact in a minute. i got these scripts from the racknine forum. they advise someone else there to use these scripts.

i’ll be back
thanks again

Hey bubba-
Well I checked and it is set to post. But hopefully you can help me out a little more…i have my scripts in flash posted below
thanks

----------------- This is the scripts on my frame which makes sure that they include something in all fields ---------------------
stop();
function lineAdapt() {
message_send = message;
while (msg_count<length(message)) {
msg_count = msg_count+1;
if ((substring(message_send, msg_count, 2)) eq “\r”) {
message_send = (substring(message_send, 1, msg_count-2)) add "
" add (substring(message_send, msg_count+2, (length(message_send))-msg_count+2));
}
}
message = message_send;
delete msg_count;
delete message_send;
}

----This is the scripts on my submitt button-----------------
on (release) {
if (customeremail eq “” or customercomment eq “” or customername eq “” or customerphone eq “”) {
stop();
} else {
lineAdapt();
loadVariablesNum(“tomweb_form2.php3”, 0, “POST”);
gotoAndStop(15);
}
}

$email_subject = '[E-mail Application]';
$email_to = '[email protected]';
$email_from_name = $_POST['customername'];
$email_from = $_POST['customeremail'];
$email_header = $_POST['customerphone'];
$email_footer = $_POST['customercomment'];
$email_redirect = '';

Try that for your first few lines instead. It might work…

awww man…that’s what you were talking about…****…thanks bro.
i’ll keep you posted again in a minute or two

Hey Jubba-
I hope you’re still there. it didn’t work.
-now am i suppose to upload this thing in ascii mode or binary?
-or does it matter at all?
-The reciepient’s email; does it have to be related to the domain? Or can it be any email address like a hotmail address?
-Also, the first line of the code ($email_subject = ‘[E-mail Application]’:wink: does the Email Application have to be something?
-I’m kinda stuck here and I hope you or someone can help me out. You guy have answered every problem i ran into so far.

please help.

thanks bro.

craschnburn

Try this instead :

if you have a loadVars object that looks like this :

[AS]
Obj.my_email_variable = "[email protected]";
Obj.message = “Hello world!”;
[/AS]

Your php code should looks like this :


    $my_email = $HTTP_POST_VARS["my_email_variable"];
    $my_message = $HTTP_POST_VARS["message"];

This is if you’re using the POST method. If you want to use the GET method, here is your code :


    $my_email = $HTTP_GET_VARS["my_email_variable"];
    $my_message = $HTTP_GET_VARS["message"];

Hey Voglio-

Thanks for replying back to me. But I’ve been trying for so long that I wanna give up. but I don’t wanna give up. I know that I’m right on the edge of things and about to understand it.

If you could check out my scripts and coding for me. I zipped up a php and fla file. If you could please check my work and advise me what I should do.

Thank you so much.

Which version of php is installed on your server?

Hey voglio-

I’m not sure…but it’s with racknine.

Okay, I suppose that you’re speaking about the Hosting Service, racknine.com.

As it written on their website, you’re running on PHP 4.3.0, which is a GOOD thing because my code will work. :slight_smile:

As I written, you don’t fetch the environment info correctly.

You wrote this :


$email_subject = '[E-mail Application]';
$email_to = '[email protected]';
$email_from_name = $_POST['customername'];
$email_from = $_POST['customeremail'];
$email_header = $_POST['customerphone'];
$email_footer = $_POST['customercomment'];
$email_redirect = '';

This won’t work - try this instead :


$email_subject = '[E-mail Application]';
$email_to = '[email protected]';
$email_redirect = '';
$email_from_name = $HTTP_POST_VARS["customername"];
$email_from = $HTTP_POST_VARS["customeremail"];
$email_header = $HTTP_POST_VARS["customerphone"];
$email_footer = $HTTP_POST_VARS["customercomment"];

Think about environment variables has an Array where you fetch the value by giving the array name (http_post_vars) and the index (the name of your variable).

If $email_redirect is a value from Flash, you should give it a variable name and fetch it like the other variables.

Another thing, and that is good for ALL OF YOU, WHO ARE READING THIS :

[COLOR=blue]Programming rule #1 : COMMENT YOUR CODE.[/COLOR]

Nothing can be more frustrating for YOU to code something, forget it and trying to get into 4 months later. In your case Tom, I can’t even find where is located the LoadVars variable. Your actionscript is also on the frame 10 (?!) and since it is not a onClipEvent(enterFrame), you should always put your code on the frame 1 of a different layer.

[COLOR=blue]Programming rule #2 : NO NEED TO OPTIMIZE YOUR CODE; THIS IS NOT A 3D ENGINE THAT YOU’RE PROGRAMMING.[/COLOR]

Let’s face it, you’re code is not for the supercomputer of NASA and if it takes 0.01 second more time to execute it, it won’t slow down your server.

Don’t be afraid to put a series of If() instead of a complex while() if this can clarify your code. You, the programmer, will win on two sides : first, it wil be easier for you to get into it in a few months and second, your debugging will be MUCH easier.

I’m seriously thinking about making a PHP/ MySQL tutorial…

Hey voglio-

I think that was the best lesson i’ve had in php. you should seriuosly make your own tutorial.

**** you’re pretty good. Thank you so much.

Everyone should know that that you are a **** good teacher.

Thank you again.

You’re welcome. :slight_smile: