PHP not working? - Page 5
A Flash Developer Resource Site

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

Thread: PHP not working?

  1. #81
    Junior Member
    Join Date
    Nov 2006
    Posts
    20
    Quote Originally Posted by Chimpanzee
    I have this code:
    PHP Code:
    <?php
     mail
    ("my@emailaddress.com"$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

  2. #82
    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!

  3. #83
    Moderator
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    flash should look like

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

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

    Musicman

  4. #84
    Junior Member
    Join Date
    Dec 2001
    Posts
    11

    Email Form working/not working

    Hi there,
    I have an email form movie with a php script which works perfectly as a standalone swf.
    The problem arise when I import the form into my website movie and make it a movie symbol, which I subsequently drag into another page and at this stage the form stops working. Must be something simple I have overlooked.
    Any ideas? Help appreciated.

    Jan
    Jappe

  5. #85
    Moderator
    Join Date
    Feb 2001
    Posts
    13,044
    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

  6. #86
    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 03:57 PM. Reason: Error
    Jappe

  7. #87
    Moderator
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

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

    Musicman

  8. #88
    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

  9. #89
    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

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

  11. #91
    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 'myemail@myemail.com';
    //---------------------------


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

  12. #92
    Moderator
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    I can occasionally help when I know an actual website url

    Musicman

  13. #93
    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

  14. #94
    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("tom@tomartin.net"$subject$message"From: $sender");
    }
    ?>
    What am I doing wrong?

  15. #95
    Moderator
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    can you just upload this php file and view it in browser?
    Code:
    <?
    mail("tom@tomartin.net", "test message", "just a test", "From: webserver@tomartin.com");
    echo "mail sent...";
    ?>
    If you do get the mail, then there might be a problem with your movie. If you dont get it, you should ask the server staff for assistance

    Musicman

  16. #96
    Junior Member
    Join Date
    Jul 2006
    Posts
    29
    Quote Originally Posted by Musicman
    Hi,

    can you just upload this php file and view it in browser?
    Code:
    <?
    mail("tom@tomartin.net", "test message", "just a test", "From: webserver@tomartin.com");
    echo "mail sent...";
    ?>
    If you do get the mail, then there might be a problem with your movie. If you dont get it, you should ask the server staff for assistance

    Musicman
    Okay, I uploaded just the that php file, and it showed up in the directory, so when I clicked on it, nothing happened. No e-mail, or anything. I take it I need to talk to the server staff now?

  17. #97
    Moderator
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    it did not even say "mail sent" then?
    Could this be a windows server with unconfigured mail function?

    Musicman

  18. #98
    Junior Member
    Join Date
    Jul 2006
    Posts
    29
    Here is all that shows up:
    http://www.tomartin.net/php.php

    Should I have renamed the php file "index" instead?

  19. #99
    Moderator
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    probably write the file again, with as simple a program as possible (e.g. notepad on windows) that does not add
    <title>Untitled Document</title>
    by itself or convert every < to &lt;

    Musicman

  20. #100
    Junior Member
    Join Date
    Jul 2006
    Posts
    29
    Such as this?
    http://www.tomartin.net/mail.htm

    Sorry, I'm relatively new to PHP

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

Poll by Flashkit.com