Results 1 to 3 of 3

Thread: Information form problem

  1. #1
    Join Date
    Jul 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Information form problem

    alright everyone, Im no pro at this HTML stuff yet, I build simple sites but have a desire to do more. I have an idea that I need some help completing. Here is what I wanna do.

    I have a button on one page of my site. When a guest clicks on that button it will take them to a whole new page that has a form on it that they will need to fill out. When they complete the form and hit submit at the bottom, the form and info they just filled out will be sent to me via email.

    I do not know what or where to get a form that I can customize the required info feilds on and I don't know how to have the info put in the form emailed to me when the user hits submit.

    Any and all help would be greatly appreicated. Thanks in advance,

  2. #2
    Join Date
    Jan 2008
    Posts
    4,167
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    You have to options, one you can use a different language such as PHP.
    Or you can use the the 'mailto:email' thing with html.
    With php you would do something like this:
    PHP Code:
    <?php
    mail
    ('email','subject','content');
    ?>
    The bright side of using this way is that it is very easy to understand and customize.
    You can also use html with this by making a form and a post for the php.
    Now if you decide to do it with HTML, you have a lot of downers on that.
    • You can't have it in the email, for example. All the info that they email will be attatched to a file for some reason
    • It will look like get data, so something like this: email=email&name=name&text=text, very hard to read.
    • Its not easy to customize at all, for example, if you type in a % it will turn out as a 37.
    • It will ask you A LOT of crap before you even get to submit the email like "This is trying to access your default mail thing. It will give away private info such as your name and email

    So I suggest doing this with php:
    Code:
    <?php
    mail('email',$_POST['sub'],$_POST['message']);
    ?>
    <form action="" method="post">
    <input type="text" name="sub" /><br />
    <input type="text" name="message" />
    <input type="submit" />
    </form>
    Jeremy | jfein.net

  3. #3
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    I agree with using php rather then HTML emailing. Once you get it set up, it's a lot easier for everyone. I personally hate those messages as well BUT, you have to keep in mind that your webhost needs to meet the requirements for emailing as well, and some don't. The webhost needs to:
    1. Be PHP enabled
    2. Have an SMTP server (which you have access to)

    And the page will need a .php extension rather then .htm (in case you didn't know).

    Also, a small correction in the PHP code-- I know it is just an example, but that code will send a blank email before the real email, which will get old really fast. (Or maybe it outputs a blank subject/message error?)
    Code:
    <?php
    if(isset($_POST['submit'])){ // <-- Will not email unless form was submitted
        mail('email',$_POST['sub'],$_POST['message']);
    }
    ?>
    <form action="" method="post">
    <input type="text" name="sub" /><br />
    <input type="text" name="message" />
    <input type="submit" name="submit" />
    </form>
    The button to redirect uses can be done using PHP:
    Code:
    <?php
    if(isset($_POST['submit'])){
        header("Location: form.php");
    }
    ?>
    <form action="" method="post">
        <input type="submit" name="submit" value="Send Email" />
    </form>
    Or javascript:
    Code:
    <script type="text/javascript">
    function emailform(){
        window.location = "./form.php";
    }
    </script>
    
    <input type="button" value="Send Email" onclick="emailform()" />
    Last edited by Jas; 03-20-2008 at 04:28 AM.
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

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
  •