Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: Forms - how do I get info to my email?

  1. #1
    Join Date
    Jun 2006
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Forms - how do I get info to my email?

    Hi, I am a newbie to CSS, but haven't a clue about forms and I'm not sure which forum to address this question - please help.
    I have used the CSS form on a website I'm working on:

    http://www.woodenteacher.org.uk/prospectus.html

    the CSS is:

    .cssform p{
    width: 300px;
    clear: left;
    margin: 0;
    padding: 5px 0 8px 0;
    padding-bottom: 75px;
    padding-left: 155px; /*width of left column containing the label elements*/
    }

    .cssform label{
    font-weight: bold;
    float: left;
    margin-left: -155px; /*width of left column*/
    width: 100px; /*width of labels. Should be smaller than left column (155px) to create some right margin*/
    }

    .cssform input[type="text"]{ /*width of text boxes. IE6 does not understand this attribute*/
    width: 180px;
    }

    .cssform textarea{
    width: 250px;
    height: 150px;
    }

    /*.threepxfix class below:
    Targets IE6- ONLY. Adds 3 pixel indent for multi-line form contents.
    to account for 3 pixel bug: http://www.positioniseverything.net/...reepxtest.html
    */

    * html .threepxfix{
    margin-left: 3px;
    }
    /* end of prospectus form */


    and the xhtml is:

    <form id="myform" class="cssform" action="">

    <p>
    <label for="user">Name</label>
    <input type="text" id="user" value="" />
    </p>

    <p>
    <label for="address">Address:</label>
    <textarea id="address" rows="5" cols="25"></textarea>
    </p>


    <div style="margin-left: 150px;">
    <input type="submit" value="Submit" /> <input type="Reset" value="reset" />
    </div>

    </form>

    </div>

    I am using a company called Streamline.net for my hosting, and they say that my account supports; PHP4, Pearl, and CGI, and I have my own personal CGI bin. I asked them for the script that I would need, but they basically said that I would have to find my own!

    Help! I've read about Post/Get but I really don't know where to start.

    ANY help will be very gratefully received.

    Laura

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    That's just the frontend of the form. In order to have it mailed to you, you need a form processing script on the server side, such as a PHP form script: http://php.resourceindex.com/Complet...rm_Processing/

  3. #3
    Join Date
    Jun 2006
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi, thanks for putting me in the right forum, but I feel the link that you have given drops me in the deep end a little!

    I would ideally like to use the CSS form that I have and apply PHP to it, if that is possible?

    Sorry, I really am on a steep learning curve (again) - is there a link, or tutorial that could explain it from the ground up?

  4. #4
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Basically what DD is saying is that your posted CSS and XHTML above are just the look of your form the visitor is filling out.

    What you need next is a confirmation page. From that page you can include a php script that when the visitor clicks the "everything is okay" button the page will send you the email you need.

    Check this link out. (it is one from the link DD provided.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

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

    Default

    The idea is that you send the data TO something from a page.
    Your page is DONE.

    But, you need another one.

    That next one will take the now-sent data and do stuff with it, like add it to a database, make a new page out of it, or "simply" send to your email.
    However, coding such a page can be complex if you don't know php/programming. It's certainly not something you can't do, but there is an easier solution.

    If you are just emailing to yourself and you don't mind annoyingly formatted emails, just search for a form interpreter or for mailer.

    They will give you a url and instructions for the form and mail it to you through their page, for free, though it'll put ads on the email or something along those lines.


    <form action="nextpage.php" method="post">

    Note that nextpage.php will be the URL (or path) of the next page... the one that interprets it. Theoretically, you can just put "mailto:some@one.com", but that requires the use of the visitor's personal email program (like outlook, etc.).
    The action is where the data is sent... this can be a page you write, a free one, or an email, but as above, that's not the best. It could even be any file on the web, but unless it's designed to interpret the form, then it won't change anything.

    The method is "post" as that is the most common one.
    That will send data behind the scenes.
    "get" appends it to the URL and sends it that way.

    If you typed in "fred" in the "name" field and clicked send, you'd get something like this:
    yourlocation.php?name=fred

    You've probably seen that before.

    It can get in the way, though, so post is a bit more common, I'd say. get has important uses too (like being able to use a link, not a form, by typing it into the URL the link goes to, etc.)
    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

  6. #6
    Join Date
    Jun 2006
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for your advice BliZZaRD and djr33, I have taken your advice on board, and found some more info on the hosting company's site. I have done the following:

    Added a .php file called "sendmail.php" whose code is:

    <?
    mail(Laura@Woodenteacher.org.uk", "Prospectus Request",
    $message,"From: $name","address");
    header(Location:http://www.Woodenteacher.org.uk/thankyou.html);
    >?


    and also a .html file called "thankyou.html" with the following code in it:

    <p>

    Thank you, your prospectus will be sent out to you shortly.

    </p>

    and also altered the xhtml form code to:

    <form id="myform" class="cssform" action="sendmail.php" method="post">

    <p>
    <label for="user">Name</label>
    <input type="text" id="user" value="" />
    </p>

    <p>
    <label for="address">Address:</label>
    <textarea id="address" rows="5" cols="25"></textarea>
    </p>


    <div style="margin-left: 150px;">
    <input type="submit" value="Submit" /> <input type="Reset" value="reset" />
    </div>

    </form>

    </div>

    But when I test it I get the following error message:

    Parse error: parse error, unexpected '@' in /home/fhlinux216/w/woodenteacher.org.uk/user/htdocs/sendmail.php on line 3


    I feel that I am going in the right direction, but am still doing something wrong - does anyone know what!?
    Last edited by Woody; 07-31-2006 at 12:26 PM.

  7. #7
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Try this:

    PHP Code:
    <?php
    $name 
    $_POST['name'];
    $address $_POST['address'];
    $message "The email you requested.\n\n";
    $email "Laura@Woodenteacher.org.uk"$_POST['email'];
    mail($email"Prospectus Request" $message"From: $name$address <>");
    header(Location:http://www.Woodenteacher.org.uk/thankyou.html);
    ?>
    you are telling the php to use the items posted from the previous page, but in the php you don't tell them where. So you need to define them.


    **This is untested, I am very tired, and only learning these post strings myself, LOL sorry if it doesn't work straight away **
    Last edited by BLiZZaRD; 07-31-2006 at 06:25 PM.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  8. #8
    Join Date
    Jun 2006
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for that BliZZaRD, but it still gives an error message, this time it says:

    Parse error: parse error, unexpected '@' in /home/fhlinux216/w/woodenteacher.org.uk/user/htdocs/sendmail.php on line 5


    The only thing I can querry is on the form xhtml were it says:
    <label for="user">Name</label>
    <input type="text" id="user" value="" />

    should there be something in there?
    I don't know what a Parse error is!

    Thanks for your help to date - especially from a different time zone!

    Laura

  9. #9
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Oops, sorry, forgot the " marks around the address. Edited the script above.

    Try again and see what. if any, errors you get.

    A parse error is: An error encountered during parsing of an input stream due to invalid syntax.

    Basically it tells you "HEY! Something is wrong with your code and I can't read it! Go back and check that you don't have a " missing or something!"
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  10. #10
    Join Date
    Jun 2006
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi again BLiZZaRD,

    I have tried the ammended script, but still get a similar error message, namely:

    Parse error: parse error, unexpected ',' in /home/fhlinux216/w/woodenteacher.org.uk/user/htdocs/sendmail.php on line 5

    Any ideas?

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
  •