Page 1 of 2

Help with PHP code for contact form!

Posted: Thu Jul 30, 2009 4:19 pm
by Chantilly_Lace
I have a contact form in flash, I'm doing AS 2.0

here's my code for the flash

Code: Select all

stop();
System.useCodepage = true;
send_btn.onRelease = function() {
    my_vars = new LoadVars();
    my_vars.sender = email_box.text;
    my_vars.subject = sbject_box.text;
    my_vars.message = message_box.text;
    if (my_vars.sender != "" and my_vars.subject != "" and my_vars.message != "") {
        my_vars.sendAndLoad("mailer.php",my_vars,"POST");
        gotoAndStop(2);
    } else {
        error_clip.gotoAndPlay(2);
    }
    my_vars.onLoad = function() {
        gotoAndStop(3);
    };
 };
 email_box.onSetFocus = subject_box.onSetFocus=message_box.onSetFocus=function () {
    if (error_clip._currentframe != 1) {
        error_clip.gotoAndPlay(6);
    }
 };


now for the php here is what I have

Code: Select all

<?php
 
/*
Note: most servers require that one of the emails (sender or receiver) to be an email hosted by same server, 
so make sure your email (on last line of this file) is one hosted on same server.
--------------------------- */
 
 
// read the variables from the string, (this is not needed with some servers).
$subject = $_REQUEST["subject"];
$message = $_REQUEST["message"];
$sender = $_REQUEST["sender"];
 
 
// include sender IP in the message.
$full_message = $_SERVER['REMOTE_ADDR'] . "\n\n" . $message;
$message= $full_message;
 
// remove the backslashes that normally appears when entering " or '
$message = stripslashes($message); 
$subject = stripslashes($subject); 
$sender = stripslashes($sender); 
 
// add a prefix in the subject line so that you know the email was sent by online form
$subject = "Contact form ". $subject;
 
// send the email, make sure you replace email@yourserver.com with your email address
if(isset($message) and isset($subject) and isset($sender)){
    mail("snowy_658@msn.com", $subject, $message, "From: $sender");
}
?>
but it won't work, is there something I'm missing? I don't understand php code at all, this is just a project I worked on in college( a few months ago) and now I need the same code for my personal site, help please!

Re: Help with PHP code for contact form!

Posted: Thu Jul 30, 2009 4:22 pm
by jackpf
What happens when you put var_dump($message), var_dump($sender)...with all your values used in the mail() function?

Re: Help with PHP code for contact form!

Posted: Thu Jul 30, 2009 4:25 pm
by Chantilly_Lace
Sorry, I don't really understand what your asking, I'm really a noob with php coding, I know nothing. But the flash contact form is just a thing where it has name, email, then message box. For the php, I member him saying in class all we had to do was put in our emails in place, we never went over php code so I don't know what any of it means. I just need the cantact form info to send to my email account

Re: Help with PHP code for contact form!

Posted: Thu Jul 30, 2009 4:29 pm
by jackpf
Well I know nothing about flash.

Put var_dump($_REQUEST); somewhere on the php page and post what it says. That should show if the flash is working.

Re: Help with PHP code for contact form!

Posted: Thu Jul 30, 2009 4:34 pm
by Chantilly_Lace
I just tryied it and nothing happened

Re: Help with PHP code for contact form!

Posted: Thu Jul 30, 2009 4:36 pm
by jackpf
What do you mean nothing?

Something must have been displayed.

Re: Help with PHP code for contact form!

Posted: Thu Jul 30, 2009 4:38 pm
by Chantilly_Lace
I put in the code, saved it, replayed the flash which is supposed to call upon the php and nothing happened. It was the same as before

Re: Help with PHP code for contact form!

Posted: Thu Jul 30, 2009 4:39 pm
by jackpf
Does the flash display the output from the php file? I'm useless with flash - I can't tell :)

Anyhow, you need to somehow be able to see the output from the php file in order to debug it...that's just logical.

Re: Help with PHP code for contact form!

Posted: Thu Jul 30, 2009 4:43 pm
by Chantilly_Lace
The flash won't show anything from the php. The code in the flash calls on the php and the php is supposed to make it so I can get the emails sent to me from the contact form in flash. There's no way for me to see the php code in the flash though

Re: Help with PHP code for contact form!

Posted: Thu Jul 30, 2009 4:45 pm
by Chantilly_Lace
ALSO I'm doing the php in dreamweaver, can I debug it from there? How would I go about doing that?

Re: Help with PHP code for contact form!

Posted: Thu Jul 30, 2009 4:46 pm
by jackpf
Well...from what I can tell, the php seems to be function correctly.

Although without being able to see any output, there's not really much more I can do to help.

Just out of curiosity, you do have an smtp server installed right?

And I have no idea, I have never used dreamweaver.

Re: Help with PHP code for contact form!

Posted: Thu Jul 30, 2009 4:49 pm
by Chantilly_Lace
maybe that's the problem, because I don't know that that is..

Re: Help with PHP code for contact form!

Posted: Thu Jul 30, 2009 4:50 pm
by jackpf
In order to send emails you need email software installed. SMTP - simple mail transfer protocol. You're pretty <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> sending emails without it.

I'd say that's your problem.

Re: Help with PHP code for contact form!

Posted: Thu Jul 30, 2009 4:53 pm
by Chantilly_Lace
I might have the software, because when I tested this in class months ago it worked. Do you mean like I'd have to have it hosted on a site by like an FTP?

I bought a website and hosting, I just have to upload everything via FTP, do you think it would work then after I uploaded it?

Re: Help with PHP code for contact form!

Posted: Thu Jul 30, 2009 4:55 pm
by jackpf
If your host has an SMTP server installed, then yes.

Although I have no way of knowing that. I'm not psychic :P The only way to find out would be to test it.