www.webdeveloper.com
Results 1 to 12 of 12

Thread: More than one actions per form?

  1. #1
    Join Date
    Jul 2006
    Posts
    12

    More than one actions per form?

    Hey

    How do I add more than action per Form?

    I have a registration form which sends data to a database on submit. I want it to send data to a mail aswell...how do I do that?

    Regards
    Dennis Ingham

  2. #2
    Join Date
    Apr 2006
    Posts
    370
    You can only have one action statement for a form... but that action can point to a script that can do any number of things.

    Here's a rough outline (treat as pseudo code... it's probably riddled with errors)

    HTML Code:
    <?php
    
    if(isset($_POST['submit'])  ){
    
        //validate
    
         //Do other stuff
         //e.g., Store in a database
        //e.g., send an email
    
    }
    ?>
    <html>
    <head>
    </head>
    <body>
    
    <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
    
    <input type="submit" name="submit" value="Save">
    </form>
    
    </body>
    </html>
    Last edited by GaryS; 07-12-2006 at 06:24 AM.

  3. #3
    Join Date
    Jul 2006
    Posts
    12
    Thanks GaryS I'll try that!

  4. #4
    Join Date
    Jul 2006
    Posts
    12
    Hi again.
    I can post the data to the database, but I can't figure out the mail - maybe it's because i'm using the wrong PHP script:

    My codes looks like this:
    <?PHP
    if (isset($_POST['submit'])){
    echo $editFormAction;

    $to = 'info@ingham-sejlerskole.dk';
    $subject = 'Ny tilmelding';
    $message ='Der er kommet en ny tilmelding';
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers = 'To: Dennis <info@ingham-sejlerskole.dk>' . "\r\n";
    $headers = 'From: Dennis Ingham <info@ingham-sejlerskole.dk>' . "\r\n";

    mail($to, $subject, $message, $headers);
    }
    ?>


    I'm a little newbie in PHP programming so...maybe I just picked up the wrong script.

    Anyone who knows how to sent mail with PHP scripting?

  5. #5
    Join Date
    Apr 2003
    Location
    Rosemount, MN
    Posts
    2,287
    I added . before the = sign. Try that.
    PHP Code:
    <?PHP
    if (isset($_POST['submit'])){
    echo 
    $editFormAction;

    $to 'info@ingham-sejlerskole.dk';
    $subject 'Ny tilmelding';
    $message ='Der er kommet en ny tilmelding';
    $headers 'MIME-Version: 1.0' "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";
    $headers .= 'To: Dennis <info@ingham-sejlerskole.dk>' "\r\n";
    $headers .= 'From: Dennis Ingham <info@ingham-sejlerskole.dk>' "\r\n";

    mail($to$subject$message$headers);
    }
    ?>
    My settings

    Browser :: FireFox 1.5
    Resolution :: 1152x864
    Connection :: Cable Modem 2Mbs

  6. #6
    Join Date
    Jan 2005
    Location
    Alicante (Spain)
    Posts
    7,742
    Quote Originally Posted by GaryS
    PHP Code:
    ?>
    <html>
    <head>
    </head>
    <body>

    <form action="<?php echo $_SERVER['PHP_SELF'?>" method="post">
    Using $_SERVER['PHP_SELF'] in that context is insecure.

  7. #7
    Join Date
    Apr 2006
    Posts
    370
    Yes, you're quite right. Laziness struck me again.

  8. #8
    Join Date
    Jul 2006
    Posts
    42
    Why is it insecure?

  9. #9
    Join Date
    Jan 2005
    Location
    Alicante (Spain)
    Posts
    7,742

  10. #10
    Join Date
    Jul 2006
    Posts
    12
    Thank you all...now it's working

    To bokeh: how can I change $_SERVER['PHP_SELF'] into a secure statement, but with the same function?

  11. #11
    Join Date
    Jan 2005
    Location
    Alicante (Spain)
    Posts
    7,742

  12. #12
    Join Date
    Jul 2006
    Posts
    12
    OK thanks 'll try that

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles