Closed Thread
Results 1 to 9 of 9

Thread: php form

  1. #1
    bunglebrown is offline x10 Sophmore bunglebrown is an unknown quantity at this point
    Join Date
    Aug 2008
    Posts
    157

    php form

    I want to put one to you that is probably glaringly obvious but bear with me. I have a simple form where users post a comment submitting their name and email address. But I can't get any of the variables to show up in the message - can anyone tell me why? ? - I'm new to it all so be gentle> lol

    PHP Code:
    <?php

    // Create local PHP variables from the info the user gave in the Flash form -disabled message field
    $fromname   $_POST['fromname'];
    $fromemail   $_POST['fromemail'];
    $fromcomments $_POST['fromcomments'];

    // Strip slashes on the Local variables -disabled message field
    $fromname   stripslashes($fromname);
    $fromemail      stripslashes($fromemail);
    $fromcomments   stripslashes($fromcomments); 

        
    $from $fromemail;
        
    $subject "my title";
        
    //Begin HTML Email Message
        
    $message = <<<EOF
    <html>
      <body bgcolor="#FFFFFF">
    <b>New entry<br />
    <b>            
    $fromemail
    <b>            <br />
    <b>            
    $fromcomments<br />
    <b>               <a href="http://www.mywebsite.com">www.mywebsite.com</a><br />
      </body>
    </html>
    EOF;
       
    //end of message
        
    $headers  "From: $from\r\n";
        
    $headers .= "Content-type: text/html\r\n";
        
    $to "myemail@myhost.com";

        
    mail($to$subject$message$headers);
        
    exit();
    ?>
    Edit:
    no-one... no?
    Last edited by bunglebrown; 09-15-2008 at 10:15 AM. Reason: Automerged Doublepost

  2. #2
    Nathan H is offline x10 Elder Nathan H is an unknown quantity at this point
    Join Date
    Apr 2006
    Posts
    562

    Re: php form

    EOF;

    have you tried removing that?

    I'll have a look in my phpIDE for you
    Last edited by Nathan H; 09-15-2008 at 11:02 AM.
    Nathan H Formerly UnFoundBug



    http://www.theadmin.co.uk - Yes i know the colours don't go, I'm working on it.

    VPS Admin | x10-commandments

    So thats where it went! I thought i was losing my mind.

  3. #3
    Nathan H is offline x10 Elder Nathan H is an unknown quantity at this point
    Join Date
    Apr 2006
    Posts
    562

    Re: php form

    A quick look in my IDE has come with loads of syntax errors, a large one being
    $message = <<<EOF

    i'll look for a solution

    I'm assuming the $fromcomments is the message you want to recieve so the modified script is below
    PHP Code:
    <?php 

    // Create local PHP variables from the info the user gave in the Flash form -disabled message field 
    $fromname   $_POST['fromname']; 
    $fromemail   $_POST['fromemail']; 
    $fromcomments $_POST['fromcomments']; 

    // Strip slashes on the Local variables -disabled message field 
    $fromname   stripslashes($fromname); 
    $fromemail      stripslashes($fromemail); 
    $fromcomments   stripslashes($fromcomments);  

        
    $from $fromemail
        
    $subject "my title"
        
    //Begin HTML Email Message 
        
    $message $fromcomments;
        echo 
    '
    <html> 
      <body bgcolor="#FFFFFF"> 
    <b>New entry<br /> </b>
    <b>            '
    .$fromemail.',   </b>
    <b>            <br />  </b>
    <b>            '
    .$fromcomments.'<br />  </b>
    <b>               <a href="http://www.mywebsite.com">www.mywebsite.com</a><br />  </b>
      </body> 
    </html> 
    '
    ;
       
    //end of message 
        
    $headers  "From: $from\r\n"
        
    $headers .= "Content-type: text/html\r\n"
        
    $to "myemail@myhost.com"

        
    mail($to$subject$message$headers); 
         
    exit(); 
    ?>
    What i changed was the html section, it is now echo to the page, and removed the EOF, incase of EndOfFile conflicts, altered the sytax error from $message = <<<EOF
    Last edited by Nathan H; 09-15-2008 at 11:09 AM.
    Nathan H Formerly UnFoundBug



    http://www.theadmin.co.uk - Yes i know the colours don't go, I'm working on it.

    VPS Admin | x10-commandments

    So thats where it went! I thought i was losing my mind.

  4. #4
    bunglebrown is offline x10 Sophmore bunglebrown is an unknown quantity at this point
    Join Date
    Aug 2008
    Posts
    157

    Re: php form

    thanks for the effort with this.

    Unfortunately I did try that and there was no content in the email so I am posting my flash actionscript code as well to make sure nothing is wrong there. Contact_Parse.php contains the php content previously posted (and then altered as advised).

    Code:
    stop();
    
    import flash.events.*;
    import flash.net.URLLoader;
    import flash.net.URLLoaderDataFormat;
    import flash.net.URLRequest;
    // ----------------------------------------------------------------
    var variables2:URLVariables = new URLVariables();
    var varSend2:URLRequest = new URLRequest("contact_parse.php");
    var varLoader2:URLLoader = new URLLoader;
    varSend2.method = URLRequestMethod.POST;
    varSend2.data = variables;
    
    submit2_btn.addEventListener(MouseEvent.CLICK, ValidateAndSend2);
    
    function ValidateAndSend2(event:MouseEvent):void{
    	
        //validate form fields
    	if(name2_txt.text=="Name") {
    		gotoAndStop(180);
    		status2_txt.text = "Please enter a name";
    	} else if(!name2_txt.length) {
    		gotoAndStop(180);
    		status2_txt.text = "Please enter a name";
    	} else if(email_addr.text=="Email Address") {
    		gotoAndStop(180);
    		status2_txt.text = "Please enter an email address"; 
    	} else if(!email_addr.length) {
    		gotoAndStop(180);
    		status2_txt.text = "Please enter an email address"; 
    	} else if(!validateEmail2(email_addr.text)) {
    		gotoAndStop(180);
    		status2_txt.text = "Please enter a valid email";
    	} else if(comments_txt.text=="Comments/Suggestions") {
    		gotoAndStop(180);
    		status2_txt.text = "Please enter a comment";
    	} else if(!comments_txt.length) {
    		gotoAndStop(180);
    		status2_txt.text = "Please enter a comment";
    	} else {
    	
      		variables2.fromname = name2_txt.text;
       		variables2.fromemail = email_addr.text;
    		variables2.fromcomments = comments_txt.text;
       		varLoader2.load(varSend2);
    		
    		gotoAndPlay(180);
    		
    	}
    }
    
    function validateEmail2(str:String):Boolean {
    	var pattern:RegExp = /(\w|[_.\-])+@((\w|-)+\.)+\w{2,4}+/;
    	var result:Object = pattern.exec(str);
    	if(result == null) {
    		return false;
    	}
    	return true;
    }

  5. #5
    Nathan H is offline x10 Elder Nathan H is an unknown quantity at this point
    Join Date
    Apr 2006
    Posts
    562

    Re: php form

    can you confirm fromname and fromemail work?
    Nathan H Formerly UnFoundBug



    http://www.theadmin.co.uk - Yes i know the colours don't go, I'm working on it.

    VPS Admin | x10-commandments

    So thats where it went! I thought i was losing my mind.

  6. #6
    bunglebrown is offline x10 Sophmore bunglebrown is an unknown quantity at this point
    Join Date
    Aug 2008
    Posts
    157

    Re: php form

    well I have since tried with a simple html form and it was all fine so I really think it must be the flash - what can I do to corner the exact problem and rectify it?

  7. #7
    Nathan H is offline x10 Elder Nathan H is an unknown quantity at this point
    Join Date
    Apr 2006
    Posts
    562

    Re: php form

    rather than using POST statements have you tried using get
    ie
    URLRequest("contact_parse.php?fromname="&name2_txt .text&"&fromemail="&email_txt.text&"&fromcomments= "&comments_txt.text)
    Nathan H Formerly UnFoundBug



    http://www.theadmin.co.uk - Yes i know the colours don't go, I'm working on it.

    VPS Admin | x10-commandments

    So thats where it went! I thought i was losing my mind.

  8. #8
    bunglebrown is offline x10 Sophmore bunglebrown is an unknown quantity at this point
    Join Date
    Aug 2008
    Posts
    157

    Re: php form

    not really - the not knowing how to do it made it quite difficult but do you think that could work? and what should I change?
    Edit:
    I just want to alert you that the problem was in the actionscript with this line:

    Code:
    varSend2.data = variables;
    which should have been:

    Code:
    varSend2.data = variables2;
    The PHP form from NathanH was useful although I altered the $message to include all of the variables. Thanks for that and to all who contributed as always.
    Last edited by bunglebrown; 09-16-2008 at 11:25 AM. Reason: Automerged Doublepost

  9. #9
    Nathan H is offline x10 Elder Nathan H is an unknown quantity at this point
    Join Date
    Apr 2006
    Posts
    562

    Re: php form

    Your welcome, I'm closing this thread, if there are any other difficulties you may reopen this thread or start a new one
    Nathan H Formerly UnFoundBug



    http://www.theadmin.co.uk - Yes i know the colours don't go, I'm working on it.

    VPS Admin | x10-commandments

    So thats where it went! I thought i was losing my mind.

Closed Thread

Similar Threads

  1. currently have an application pending php
    By biomasti in forum Free Hosting
    Replies: 1
    Last Post: 09-03-2008, 01:58 PM
  2. php contact form in flash not working.
    By eddbrown in forum Free Hosting
    Replies: 2
    Last Post: 08-13-2008, 03:16 PM
  3. Easy XHTML form validation using PHP
    By Xemnas in forum Tutorials
    Replies: 0
    Last Post: 01-08-2008, 04:29 AM
  4. Cambios IMPORTANTES en PHP.
    By Fedlerner in forum Noticias y Anuncios
    Replies: 1
    Last Post: 11-06-2007, 11:13 AM
  5. Sigo con problemas con phpbb2
    By reciecho in forum Soporte
    Replies: 7
    Last Post: 10-20-2007, 06:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers