Results 1 to 5 of 5

Thread: Send whole text by e-mail (using forms?)

  1. #1
    Join Date
    May 2007
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Send whole text by e-mail (using forms?)

    Hi

    I want to make a "fill the gap" type of game on a webpage, which should:
    - have text with gaps that visitor should fill. A la "Hey, fill _____ gap!"
    - The text WITH the filled gaps in RIGHT PLACES should be then sent to a certain e-mail address. This e-mail must contain this whole text, a la "Hey, fill this gap!"

    I can easily let a form send me single words, but I'd like this sent e-mail to send the whole text with the words in right places.

    How can I do this?


    Thanks!

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Create a copy of the text and replace blanks with the variables.
    For example: "some text %BLANK1% some text..."
    In PHP you can use str_replace() to do this, or you could use various other methods.
    For specific help, give us a link to your website or post the code you are using.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    May 2007
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi djr33!

    This is what I have at the moment... (I'm using Saurus CMS/Smarty and all this is in the article code):

    HTML Code:
    <form action="form.php" method="post" name="SCMSForm">
        <input type="hidden" value="email@example.com|||index.php?id=28008&tpl=1062|||index.php?id=28007|||Lüngamäng" name="_systemfield" style="margin-top: 1px; font-size: 11px; line-height: 12px; font-family: Arial; height: 18px; background-color: rgb(204, 204, 204);" /> <input type="hidden" name="id" value="2611" /><input type="hidden" name="actionEvent" value="send_form" />
        <p>
        <table width="100%" cellspacing="0" cellpadding="1" border="0">
            <tbody>
                <tr>
                    <td colspan="2">"Palun taltsuta mind," ütles ta siis."<input type="text" size="10" name="gap1" class="valjad_laste" /> tahaksin," vastas väike <input type="text" size="10" name="gap2" class="valjad_laste" />,"ent mul pole kuigi palju aega. Mul on vaja endale <input type="text" size="10" name="gap3" class="valjad_laste" /> leida ja paljusid asju tundma õppida.""Tuntakse ainult neid asju, mida taltsutatakse," ütles rebane." Inimestel pole enam aega midagi tundma õppida. Nad ostavad kõiki asju valmis kujul kaupmeeste käest. Ja kuna ei ole kaupmehi, kes sõpru müüksid, siis polegi inimestel enam sõpru. Kui tahad endale sõpra, siis taltsuta mind!"</td>
                </tr>
            </tbody>
        </table>
        </p>
        <p>*</p>
        <table align="left">
            <tbody>
                <tr>
                    <td><strong>Send it to us</strong></td>
                    <td>*</td>
                </tr>
                <tr>
                    <td valign="middle" align="right">Your name<span style="color: rgb(255, 0, 0);">*</span>:</td>
                    <td><input type="text" size="25" name="r_sinu_nimi" class="valjad_laste" /></td>
                </tr>
                <tr>
                    <td valign="middle" align="right">Your mail<span style="color: rgb(255, 0, 0);">*</span>:</td>
                    <td><input type="text" size="25" name="e_email" class="valjad_laste" />*</td>
                </tr>
                <tr>
                    <td valign="top" align="right">Age:</td>
                    <td><input type="text" size="25" name="vanus" class="valjad_laste" /></td>
                </tr>
                <tr>
                    <td valign="top" align="right">*</td>
                    <td><img style="height: 38px; padding-bottom: 2px; padding-top: 2px;" alt="" src="/extensions/saurus4_captcha/captcha_image.php?name=default" /></td>
                </tr>
                <tr>
                    <td align="right">Insert code<span style="padding: 0px; color: rgb(255, 0, 0);">*</span>:</td>
                    <td><input type="text" name="captcha_default" style="border: 1px solid rgb(133, 173, 24);" /> <br />
                    <span style="font-size: 10px; color: rgb(85, 85, 85);">[<span style="color: rgb(255, 0, 0);">*</span> - required fields]</span></td>
                </tr>
                <tr>
                    <td align="right">*</td>
                    <td>*</td>
                </tr>
                <tr>
                    <td>*</td>
                    <td><input type="submit" name="__" value="Send" class="submit_laste" />* <input type="reset" name="__" value="Reset" class="submit_laste" /></td>
                </tr>
            </tbody>
        </table>
        <p>*</p>
    </form>

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    That's just the html. The result will be something generated after that data is sent.

    The action on the form needs to point to the php script (or other language) used to process the form, then you can access the post data like this:
    $_POST['fieldname']

    As I said above, you can use str_replace to replace each item individually in the "story" you write using variables like above.

    Or you can just do it directly with variables:
    echo "Once upon a time there was a ".$_POST['job']." who liked to ".$_POST['activity'].". One day his ".$_POST['familymember']." said.........";

    That would output something like:
    Once upon a time there was a farmer who liked to swim. One day his uncle said......



    I hope that gets you started.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Jul 2009
    Location
    Washington (USA)
    Posts
    94
    Thanks
    3
    Thanked 3 Times in 3 Posts

    Default

    Will something like this work? It requires only 1 PHP page.

    Code:
    <?php
    
    if(isset($_POST['submit'])) {
    
    $to = "YOUR_EMAIL_GOES_HERE";
    $name=$_POST['name'];
    $email=$_POST['email'];
    $age=$_POST['age'];
    $subject = "Form has been completed by $name";
    $blank1=$_POST['blank1'];
    $message = "
    Name: $name\n
    Email: $email\n
    Age: $age\n\n
    First Blank: $blank1
    ";
    $headers = "From: $email";
    
    mail($to,$subject,$message,$headers);
    
    echo "Thank You!";
    
    }
    
    ?>
    <html>
    <head>
    <title>My Form</title>
    </head>
    <body>
    <form method="post">
    <input type="text" name="name" id="name"><br>
    <input type="text" name="email" id="email"><br>
    <input type="text" name="age" id="age"><br><br>
    Hey, <input type="text" name="blank1" id="blank1">!
    <br><br>
    <input type="submit" value="Submit">
    </form>
    </body>
    </html>
    Add more 'blank#'s to add more blanks.

Bookmarks

Posting Permissions

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