Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Junior Member ItalianMike's Avatar
    Join Date
    Nov 2004
    Posts
    28
    Member #
    8321
    I found a PHP mail form and applied it to me website (here), it works fine but I have one beef with the script. If there is an error, for example not all fields are filled in, when you hit submit it goes to a separate error page. If there are no problems and you submit it goes to a separate thank you page.

    What I like for it to do is to make these changes on the actual contact page. I'm not at all into PHP but I'm one hell of a reverse engineer. Can anyone point me in the direction of a tutorial that does it this way, or maybe some source codes to analyze?

    It would be greatly appreciated

  2.  

  3. #2
    Senior Member karinne's Avatar
    Join Date
    Dec 2003
    Location
    Aylmer QC Canada
    Posts
    1,607
    Member #
    4335
    Liked
    8 times
    you can do something like

    Code:
    if ($_POST['submit']) {
      if (empty($_POST['name']) or .....) {
        echo 'fields are missing';
        echo 'form....';
      } else {
        echo 'thank you....';
      }
    } else {
     echo 'form....';
    }
    [a web design portfolio - Currently NOT AVAILABLE for work | web design | Re-coding | PSD-to-HTML]
    I'm also on: virb - facebook - twitter - flickr - del.icio.us

  4. #3
    Junior Member ItalianMike's Avatar
    Join Date
    Nov 2004
    Posts
    28
    Member #
    8321
    got it done with some help from the tutorials section

  5. #4
    Junior Member
    Join Date
    Jun 2005
    Posts
    3
    Member #
    10268
    This is exactly what I'm looking for as well..

    I have a simple php script for form on my html page, but whenever user sends something, the (html) page refreshes to a new page.

    I'd like to use custom pages for "sent" and "error" pages.

    Or even better, I'd just like to display a line of text below the actual form after the submit button is pressed.

    Can someone help me with this? Pls!!

    TIA


    P.S.
    I'm a php newbie, so even the creation of the actual php form was a bit of a challenge to me, so pls, as simple as possible..

  6. #5
    Senior Member seanmiller's Avatar
    Join Date
    Sep 2003
    Location
    Glastonbury, UK
    Posts
    868
    Member #
    3263
    Liked
    1 times
    You have two options..

    a) Make the form submit the data to itself (ie. the same page)... this way all the $_POST[] variables will be available to it, so it can not only validate the data but if it doesn't like something it can re-display the form with the data intact (just stick a <? php echo $_POST['name']; ?> in the input field) and an appropriate error message below. Obviously if the validation succeeds it puts the appropriate "Thank you" text instead.
    b) Write some Javascript validation that runs when the submit button is pressed.

    You could also fire the Javascript when each individual field is entered. On thing, though, you would need to consider having any important validation server-side too as Javascript can be disabled by the visitor.

    Here's a Javascript tutorial... http://www.xs4all.nl/~sbpoley/webmatters/formval.html

    Sean

  7. #6
    Junior Member
    Join Date
    Jun 2005
    Posts
    4
    Member #
    10369
    There is a much simpler way to do this than using JS.
    For example you use the isset function. As shown below.

    if(!isset($_POST['submitbutton'])) {
    Display your form here etc
    } else {
    put all your mail code here etc to send the email to yourself after the form is submitted.

    Then display your message after that code
    }

    You have to remeber though to put the action of the form as the same page the form is on.

    This is a nice and compact method and saves using multiple files and gives you control over when to show a message. You can even show an error message if something goes wrong as an extra option.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 08:30 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com