A Flash Developer Resource Site

Page 5 of 7 FirstFirst 1234567 LastLast
Results 81 to 100 of 126

Thread: PHP not working?

Hybrid View

  1. #1
    imagination through stupidity
    Join Date
    Apr 2001
    Location
    P3X-3113
    Posts
    1,238
    this thread is 4 years old, people keep on bringing it up. lol
    Nothing to see here, move along.

  2. #2
    Senior Member
    Join Date
    Jul 2000
    Posts
    356
    That's coz it's a 'sticky' at the top of the forum category. I wonder what happened to Musicman, I thought he was helping me?
    Healthy Earth - Healthy Mankind - A Joyous New Millennium

  3. #3
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi,

    right from the message that the server sends back to the browser:
    Sorry, but I cannot figure out who sent you here. Your browser is not sending an HTTP_REFERER. This could be caused by a firewall or browser that removes the HTTP_REFERER from each HTTP request you submit.
    For many years it was just internet exploder that did not send a referer along with flash requests (and hence made this kind of php script useless) - since a while Mozilla seems to duplicate that behaviour as well.

    While referer check is a quite common way to add a bit of safety to formmail scripts, and more or less the only way for shared scripts (ones that a hosting company sets up for all their non-php users), it is fairly easy to trick these scripts and supply an acceptible referer, along with an arbitrary recipient (any many a spammer these days uses some website formmail to advertise their stuff)
    Since it is your own script, dispose of the referer check, hardcode the recipient address in your script (so if someone tries to send to a test address it goes to your inbox insetad, and therefore is not useful for a spammer), and rather ensure that any field which goes into the mail header (the email as From: or Reply-To:, or the subject) is really one line

    Musicman

  4. #4
    Senior Member
    Join Date
    Jul 2000
    Posts
    356
    Musicman, thank you very much for your explanation. When I said the PHP script was mine, I didn't mean 'mine', I just meant I had access to it, and could change it.

    I believe my server / hosting company won't process PHP formmail unless it has the 'referrer' for spam reasons. However, I may be misunderstanding which 'referrer' you mean. I'm only vaguely familiar with PHP. Could you please look at my PHP code [below], and show me which 'referrer check' to dispose of and where to put the recipient address? I would very much appreciate your help. Thanks again...

    <?PHP
    define('VERSION','Classic v1.07.0');
    define('MANUAL','http://www.boaddrink.com/projects/phpformmail/readme.php');
    define('CHECK_REFERER', true);

    // Variables sent from my Flash Form;
    $corps=$name."\n".$admail."\n".$phone."\n".$referr ed."\n".$website."\n".$message."\n";
    mail($recipient,$subject,$corps,"From: $admail\nReply-To:$admail\nX-Mailer: PHP/");

    $referers = array('www.mediashox.com', 'mediashox.com', '208.106.175.228');

    $valid_env = array('REMOTE_HOST', 'REMOTE_ADDR', 'REMOTE_USER', 'HTTP_USER_AGENT');

    $recipient_array = array();

    // +------------------------------------------------------------------------+
    // | |
    // | SMTP Modification by: CrystalTech Web Hosting Inc. |
    // | Modified Date: 09.16.05 |
    // | Modification approved for PHPFormMail Classic v1.07.0 |
    // | |
    // +------------------------------------------------------------------------+
    // | |
    // | Please enter a Valid Mail Server for your Email Recipient: |
    // | If the recipient is [email protected], then the SMTP server should |
    // | be mail.yourdomain.com - For additional support, please email |
    // | [email protected] |
    // | |
    // +------------------------------------------------------------------------+

    // Please specify your Mail Server - Example: mail.yourdomain.com.
    ini_set("SMTP","mail.mediashox.com");

    // Please specify an SMTP Number 25 and 8889 are valid SMTP Ports.
    ini_set("smtp_port","25");

    // +------------------------------------------------------------------------+
    // | STOP EDITING! The only two required variables that need to be updated |
    // | are $referers and $valid_env |
    // +------------------------------------------------------------------------+
    Healthy Earth - Healthy Mankind - A Joyous New Millennium

  5. #5
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi,

    the line about CHECK_REFERER near the top seems to be a good place to change...
    Now, about hardcoding recipient .... just go to the webpage listed in the MANUAL entry and read about the $recipient_array

    Musicman

  6. #6
    Senior Member
    Join Date
    Jul 2000
    Posts
    356
    Musicman,

    I changed the following:

    1 -- define('CHECK_REFERER', false);

    2 -- $recipient_array = array('fcf7b465cc30923b02a8cecc2ede239331c7990e' => '[email protected]', ' 2bd7df9fbc9f87040e617b5c09ad16aa85d73ecc ' => '[email protected]');

    Both as per the MANUAL.

    The form still does not work. I am not receiving the emails.

    As stated earlier, the PHP file has been tested with an HTML form, and it works perfectly.

    It seems that Flash will not talk to the PHP file.

    Thanks
    Healthy Earth - Healthy Mankind - A Joyous New Millennium

  7. #7
    Junior Member
    Join Date
    Nov 2006
    Posts
    20
    I have this code:
    PHP Code:
    <?php
     mail
    ("[email protected]"$subject$message"From: $fromname
    Reply-To: 
    $fromemail
    X-Mailer: PHP/" 
    phpversion());
     
    ?>
    which i believe needs to be fixed as register_globals is off on my server. Could someone let me know how to do this.
    Thanks.

  8. #8
    Junior Member
    Join Date
    Nov 2006
    Posts
    20
    Quote Originally Posted by Chimpanzee
    I have this code:
    PHP Code:
    <?php
     mail
    ("[email protected]"$subject$message"From: $fromname
    Reply-To: 
    $fromemail
    X-Mailer: PHP/" 
    phpversion());
     
    ?>
    which i believe needs to be fixed as register_globals is off on my server. Could someone let me know how to do this.
    Thanks.
    if you need it, my php info is at http://www.laurentobia.com/phpversion.php

  9. #9
    Junior Member
    Join Date
    Apr 2007
    Posts
    1
    Hi All,

    Can someone please help me out been stuck on trying to solve this issue for a while now and cant figure out why it isnt working.

    As the Point of this whole thread is about PHP not recieving variable from flash, i thought this would be the best place to put it!

    The Variables are assigning correctly in flash but when passing them to PHP nothing is in the $_POST array

    Here is my flash code and PHP

    [Flash Code]var msg:LoadVars = new LoadVars();
    var TScore = "465";
    var TName = "Testing"
    msg.nName = nName.text;
    msg.score = Score.text;

    phpResult.text = msg.toString();

    msg.send("WebsiteAddress.php","_parent","POST");[/Flash Code]

    PHP Code:
    <html>
    <head>
    <title>Basic PHP</title>
    </head>
    <body>
    <?php
        $link 
    mysql_connect("localhost""blah""blah");
            if(!
    $link) {
                
    // no database link, handle appropriately
        
    } else { // we have db, lets continue!
                
    $result mysql_select_db("awm_eq264145"$link);
                    if(!
    $result) {
                        
    // no db selection, handle appropriately
                    
    } else { // we have our db, lets continue!
    $query "INSERT INTO assignment (Name, Score) VALUES ('" .$_POST['nName']."','"$_POST['score']."')";
                         if(
    mysql_query($query,$link)){
                        
    //if the query was successfully sent, get the number of rows
                        
    $rows_affected mysql_affected_rows($link);
                    } else {
                        
    printf("<pre>");
                        
    print_r($_POST);
                        
    printf("</pre>");
                        
    printf($query);
                        
    printf("bollox didnt work");
                        }
                    }
            }
    ?>
    Can someone please point out where the bloody hell i am going wrong please, its doing my head in!

  10. #10
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi,

    flash should look like

    var msg:LoadVars = new LoadVars();
    msg.TScore = "465";

    msg.send("WebsiteAddress.php","_parent","POST");

    Musicman

  11. #11
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi,

    this sounds very much like the old loadvariablesnum with level 0 or _root as a target.
    Once your movie works with loadvariables and relative target (this, _parent) or a loadvars object, it should work by itself and as part of a bigger movie

    Musicman

  12. #12
    Junior Member
    Join Date
    Dec 2001
    Posts
    11

    PHP script

    Thanks for the reply!
    What I have is the following:

    on (release) {
    sender_mail = _root.Semail.text
    sender_name = _root.Sname.text
    sender_subject = _root.Ssubject.text
    sender_message = _root.Smessage.text
    loadVariables("sendmail.php",this,"POST");

    this.onData = function()
    {
    for(var a in this) trace([a,this[a]])

    _root.nextFrame();
    if(this.output=='sent')
    {
    _root.errTitle = 'Thank You.';
    _root.errType = "Your message has been succesfully sent.";
    } else {
    // else
    _root.errTitle = "Error!";
    _root.errType = "Attention, an error occurred while processing your message. Please try again later.";
    }
    }
    }


    Funny that it works on it's own though!
    Is there such a thing in flash that you cannot place a movie symbol within another movie symbol for the php script to work? Simply asking because it seems odd for it work when in a standalone, but not when imported.

    Thanks again!
    Jan
    Last edited by jappe; 05-30-2007 at 02:57 PM. Reason: Error
    Jappe

  13. #13
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi,

    are you sure your text fields are still in the _root?

    Musicman

  14. #14
    Junior Member
    Join Date
    Dec 2001
    Posts
    11
    You may well have a point there Musicman!
    As I have trawled the net for a solution, I understand that there is a common problem attached to the use of _root and that _root infact is regarded as poor practice.
    With regard to my example above, is there any way to re-write the code to avoid _root ?

    Thanks again!
    Jan
    Jappe

  15. #15
    Junior Member
    Join Date
    Dec 2001
    Posts
    11
    That did the trick! Simply replaced all _root with _parent and "hey presto"!
    Thanks again Musicman!

    Best Regards

    Jan
    Jappe

  16. #16
    Junior Member
    Join Date
    Jul 2007
    Posts
    3
    had the same exact problem

  17. #17
    Junior Member
    Join Date
    Jan 2008
    Posts
    27
    not sure if this is the right post to get some help with this but my flash isnt communicating with my php file for sending email from flash

    Code:
    var sendData_lv:LoadVars = new LoadVars();
    var receiveData_lv:LoadVars = new LoadVars();
    var formValidated:Boolean;
    var errorMessages:Array = new Array();
    
    receiveData_lv.onLoad = function():Void{
    	trace(this.sent);
    	if(this.sent == "OK"){
    	 message0_txt.text = "Thank you for your Request, I will be intouch with you shortly";
    	}else{
    	 message0_txt.text = this.sent;
    		}
    }
    
    
    submit_btn.onRelease = function() {
    	//this clears the error text field if they have been populate previously
    	clearTextFields();
    	errorMessages.length = 0; //empty the array so next time the submit button is clicked the array is not already populated
    	formValidated = checkForm();
    	if (formValidated) {
    	//the form is valid and so now we can send details to our PHP file
    	//populate LoadVars object with the field values
    	sendData_lv.name = name_txt.text;
    	sendData_lv.email = email_txt.text;
    	sendData_lv.phone = phone_txt.text;
    	sendData_lv.request = request_txt.text;
    	//trace(sendData_lv.email);
    	//trace("valid");
    		sendData_lv.sendAndLoad("email1.php"+new Date().getTime(), receiveData_lv);
    	} else {
    		//populate textfields with the error messages
    		for (var i = 0; i<errorMessages.length; i++) {
    			 _root["message"+i+"_txt"].text = errorMessages[i];
    			  trace(errorMessages[i]);
    		}
    	}
    };
    
    
    function checkForm():Boolean {
    	//check whether the name field is empty
    	if (name_txt.text == "") {
    		errorMessages.push("Please enter your name.");
    	}
    	if (email_txt.text == "") {
    		errorMessages.push("Please enter your email address.");
    	} else if (email_txt.text.indexOf("@") == -1 || email_txt.text.indexOf(".") == -1) {
    		errorMessages.push("Please enter a valid email address.");
    	}
    	if (request_txt.text == "") {
    		errorMessages.push("Please enter Request information");
    	}
    	//if at this point the array is empty i.e has length 0, then this in effect means the form has passed all checks
    	if (errorMessages.length == 0) {
    		return true;
    	} else {
    		return false;
    	}
    }
    
    
    function clearTextFields():Void {
    	for (var i = 0; i<errorMessages.length; i++) {
    		_root["message"+i+"_txt"].text = "";
    ;
    	}
    }
    PHP Code:
    <?php
    $name 
    $_POST['name'];
    $email $_POST['email'];
    $phone $_POST['phone'];
    $request $_POST['request'];
    $subject 'Request from your website';
    $headers "From: $name <$email>\n";
    $headers .= "Reply-To: $name <$email>\n";


    //ENTER YOUR EMAIL ADDRESS HERE
    $to '[email protected]';
    //---------------------------


    $success mail($to$subject$request$headers);
    if(
    $success){
    echo 
    '&sent=OK';
    }else{
    echo 
    '&sent=Error';
    }
    ?>

  18. #18
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi,

    I can occasionally help when I know an actual website url

    Musicman

  19. #19
    Junior Member
    Join Date
    Jan 2008
    Posts
    27
    Quote Originally Posted by Musicman
    Hi,

    I can occasionally help when I know an actual website url

    Musicman
    www.parkagencywest.com

  20. #20
    Junior Member
    Join Date
    Jul 2006
    Posts
    29
    Okay, I can't figure out why this isn't working. I'm trying to send an e-mail from my flash site, and it acts like it's going through, but I'm not getting any of my test e-mails.

    Here is my AS:
    PHP Code:
    stop();
    send_btn.onRelease = function() {
        
    my_vars = new LoadVars();
        
    my_vars.sender email_box.text;
        
    my_vars.subject subject_box.text;
        
    my_vars.message message_box.text;
        if (
    my_vars.sender != "" and my_vars.subject != "" and my_vars.message != "") {
            
    my_vars.sendAndLoad("email.php"my_vars"POST");
            
    gotoAndStop(25);
        } else {
            
    error_clip.gotoAndPlay(25);
        }
        
    my_vars.onLoad = function() {
            
    gotoAndStop(26);
        };
    };
    email_box.onSetFocus subject_box.onSetFocus=message_box.onSetFocus=function () {
        if (
    error_clip._currentframe != 1) {
            
    error_clip.gotoAndPlay(6);
        }
    }; 
    And here is my PHP.
    PHP Code:
    <?php

    $subject 
    $_REQUEST["subject"];
    $message $_REQUEST["message"];
    $sender $_REQUEST["sender"];

    $full_message $_SERVER['REMOTE_ADDR'] . "\n\n" $message;
    $message$full_message;

    $message stripslashes($message); 
    $subject stripslashes($subject); 
    $sender stripslashes($sender); 

    $subject "Contact form "$subject;

    if(isset(
    $message) and isset($subject) and isset($sender)){
    mail("[email protected]"$subject$message"From: $sender");
    }
    ?>
    What am I doing wrong?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center