2 replies
Can anyone suggest a very simple script that I can incorporate into my site for viewers to submit articles? This can be done via email it doesn't have to be complicated. The only thing that I would like is to have an html or text input so that articles can be edited on the fly.

Any help would be appreciated.
#article #form
  • Profile picture of the author Bruce Hearder
    Hi..

    An HTML form cannot send email. So to get the content out of an form and sent somwhere else (via email or whatever), it will have to go via a script that runs on your webserver.
    This script will have be be something like a PHP or ASP script.

    Below is the HTML code for a form that will display a form on a webpage (just insert code betwteen the <body> </body> tags of your html file, and then the following code will take the results of this form and email it to you.

    Please note; the PHP code is very basic, is does not error checking. It just takes the content and sends it to you. Nothing more!!

    It should be enough to get you going.

    Of cousre you will need to change the email address to the one you want to use.
    Replace the phrase

    PUT_YOUR_EMAIL_ADDRESS_HERE

    with your email address. Make sure the email address is surrounded by dingle quotes (the ' symbol)


    I hope this helps

    Bruce

    ----------------- HTML CODE OF FORM ------

    <form method="POST" action="addarticle.php">
    <table align="center" border="0" cellspacing="0" cellpadding="10" bgcolor="#FFFFFF">
    <tr>
    <td valign="top" colspan="2">
    <p align="center"><b><font face="Verdana" size="6">Add An Article</font></b></td>
    </tr>
    <tr>
    <td valign="top"><font face="Verdana" size="2">Article Title</font></td>
    <td><font face="Verdana"><input type="text" name="article_title" size="44"></font></td>
    </tr>
    <tr>
    <td valign="top"><font face="Verdana" size="2">Author's Full Name</font></td>
    <td><font face="Verdana"><input type="text" name="author_name" size="44"></font></td>
    </tr>
    <tr>
    <td valign="top"><font face="Verdana" size="2">Text<br>
    &nbsp;</font></td>
    <td><font face="Verdana"><textarea rows="18" name="article_text" cols="56"></textarea></font></td>
    </tr>
    <tr>
    <td valign="top"><font face="Verdana" size="2">First Name</font></td>
    <td><font face="Verdana"><input type="text" name="firstname" size="44"></font></td>
    </tr>
    <tr>
    <td valign="top"><font face="Verdana" size="2">Last Name</font></td>
    <td><font face="Verdana"><input type="text" name="lastname" size="44"></font></td>
    </tr>
    <tr>
    <td valign="top"><font face="Verdana" size="2">Your Email Address</font></td>
    <td><font face="Verdana"><input type="text" name="email" size="44"></font></td>
    </tr>
    <tr>
    <td colspan="2" align="center">
    <font face="Verdana">
    <input type="submit" value="Submit Article" name="submitarticle"></font></td>
    </tr>
    </table>
    </form>

    ----------------------

    Cut and paste the following code into notepad, and then save as addarticle.php and FTP up to your server, and put in the same directory as your form is going to be in..


    ----------------------------------- PHP CODE -------
    <?php

    if (isset($_POST['submitarticle']))
    {
    $subject = 'New Article';
    $adate = date("F j, Y, g:i a");
    $email = 'PUT_YOUR_EMAIL_ADDRESS_HERE';
    $text = trim($_POST["article_text"]);
    $text = nl2br(wordwrap($text,60));
    $message = '<html>
    <head>
    <title>'.$subject.'</title>
    </head>
    <body>
    <p> Hi,</p>
    <p></p>
    <b>First Name :</b>'.$_POST["firstname"].'<br>
    <b>Last Name :</b>'.$_POST["lastname"].'<br>
    <b>E-mail :</b>'.$_POST["email"].'<br>
    <b>Date Submitted :</b> '.$adate.'</br>
    <p></p>
    Has submitted article : <b>'.$_POST["article_title"].'</b><br>
    <b>Author\'s Name : </b>'.$_POST["author_name"].'<br>
    <b>Text:</b><br>'.$text.'<br>
    <br>
    </body>
    </html>';
    $headers = "MIME-Version: 1.0\r\n";

    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    /* additional headers */
    mail($email, $subject, $message, $headers);
    echo 'All done<br>';
    }
    ?>
    {{ DiscussionBoard.errors[1320530].message }}
    • Profile picture of the author carbee57
      Thanks for the help.
      {{ DiscussionBoard.errors[1322776].message }}

Trending Topics