Page 7 of 7 FirstFirst ... 567
Results 61 to 63 of 63

Thread: PHP email form for dummies???

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

    Default

    You can also learn just as well by practicing. But that means you'll be limited in what you can do as you learn and it won't necessarily be fast. That said, you can do trial and error to make almost anything, but that won't help much for paid projects like this (since you don't have infinite time to do them).

    A redirect would be a code at the beginning of your page that would redirect the user if the form was filled out incorrectly. (And you'd probably want to quit execution of the current page so the form is not submitted even if the redirect is ignored.) So, no, you don't need a new PHP page. A redirect can be on the receiving page directing back to the form page.

    Yes, 'myfield' is an example. Replace that as needed, or (if you want) rename the field in your form to 'myfield' as well. They just need to match.
    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

  2. The Following User Says Thank You to djr33 For This Useful Post:

    katiebugla (09-02-2011)

  3. #62
    Join Date
    Jul 2011
    Posts
    113
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default

    Ok, so a couple more dumb questions:

    1) Would you be willing to walk me through a redirect?

    2) I currently just have a form, no fields - if I were to name the form 'myfield' would that be the solution? OR do I need to make a field tag within the form?

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

    Default

    A 'field' just refers to an input in the form. So it might be a textbox or a select menu or a checkbox. All are seen in PHP in the $_POST array (or $_GET if you use that method-- not so common), and there's no difference except what types of data (such as true/false, 1/0, text, a preset list of terms, etc.). So this means you should rename your textbox input name="myfield" (for example).


    As for a redirect, you can find lots of information about that by searching. The basic answer is the following: since it is done through a header, it must be sent before any HTML output to the browser, including even line breaks. This means you'll need to pre-process the form data (at least the 'myfield' value to see if it is valid) and if you need to redirect do it early, so check if the value is INVALID then redirect if that's the case.

    http://php.net/manual/en/function.header.php
    PHP Code:
    <?php header('Location: http://www.example.com/'); ?>
    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

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
  •