dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Extremely simple PHP email form

Hybrid View

  1. #1
    Senior Member
    Join Date
    Jan 2003
    Posts
    103

    Extremely simple PHP email form

    Hey guys, I'm trying to make the absolute simplest PHP form. I've tried a bunch of forms I found online, but they're all much more complex than I need them to be and when I edit them down they don't work anymore (probably because I have no idea what I'm doing in PHP).

    Here's what I'm trying to accomplish. ONE single-line text box with one submit button. Upon clicking submit, I would like it to send an email to my email address. I don't even care how the email is formatted, and the only "check" I'd like to have is if the form is empty. No formatting checks, no user email entry, nothing else. Just one box and a submit button. Does anybody have a quick template they could share that could accomplish this? I'd really, really appreciate it! Thanks!

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

    I do not have a real example for you (and it depends on which version flash/actionscript you are using),
    but even this simple project makes sense to build in stages.
    So here is the php stage - create a file, say "feedback.php" reading
    Code:
    <?php
    mail("me@somewhere.com", "website feedback", "this is where the message would go", "From: webserver@mysite.com");
    print "message sent";
    ?>
    Upload it to your server and visit it in your browser. If you see the "message sent" text AND receive a mail, you can go on to making the flash form

    Musicman

  3. #3
    Member
    Join Date
    Jul 2011
    Posts
    51
    Yanathin: You have to give some detailed information about your server setup. This might help us to understand what you are trying to do. You don’t have to answer in technical terms. Just answer the following question after make it sure.

    1. Are you put this PHP Form in a web server, and want to send email to that particular domain web-mail?

    2. Is this PHP Form will sent mail to some other mail service provider’s mail system, like gmail, yahoo mail etc.?

    3. Is this are going to run from localhost (mean from your own computer), and send mail to gmail?

    4. Or none of the above?

    This will create a simple form with single input field and a submit button to send some data of the browser:

    PHP Code:
    <?PHP
        
    function send_mail(){
            global 
    $error;
            if(isset(
    $_POST["message"]) && $_POST["message"]!=="message"){
                
    // here goes the mail or phpMailer function        
                
    $error "Thank You : Mail has been send.";
            }else{
                
    $error="ERROR";
            }    
        }
        
    $currentFile $_SERVER["PHP_SELF"];
        
    $path Explode('/'$currentFile);
        
    $send=$path[count($path)-1];
        
    $email="";
        if(!isset(
    $_GET["content"])){
            
    $message="message";
        }elseif(isset(
    $_POST["email"])){
            
    $message=$_POST["message"];
        }elseif(!isset(
    $_POST["email"]) && isset($_GET["content"])){
            
    $message="message";
        }
        
    $error="";
        if(isset(
    $_POST["email"])){    
            
    $email=$_POST["email"];
            
    $message=$_POST["message"];
            
            if(!
    $email){
                
    $error="ERROR";        
            }else{
            
    send_mail();
            }
        }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <title>PHP Mail Form</title>
        </head>
        
        <body style="margin:0px;">
            <div style="margin:auto; width:350px; padding:5px;">
                <div><?PHP echo $error?></div>
                <form action="<?PHP $send?>?content" method="post" >
                Email: <br />
                <input name="email" type="text" id="email"  value="<?PHP echo "$email"?>" />
                <br/>
                Message: <textarea name="message" id="message" cols="50" rows="10" ><?PHP echo "$message"?></textarea>
                <br/>
                <input name="submit" type="submit" value="Submit" />
                </form>
            </div>
        </body>
    </html>

    Best Wishes
    FFA

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