The forums have permanently moved to This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 3 of 3

Thread: Echo Function in a PHP Mail Form

  1. #1

    Echo Function in a PHP Mail Form

    Hi, I'm trying to learn what all the variables in PHP mean, and how they make a website function. I read the PHP Mail form turtorial on the site, and integrated it into my site, and that part is working great (receiving form submissions, etc).
    The only problem I'm having is in what happens once you click submit.
    Currently, once you click submit it takes you from the page to the text that is in the echo function (i.e. "Thanks for submitting your information")
    I really would like to know how I can manipulate the PHP form so that when someone clicks submit, it still sends the information, but stays on the same page.
    Any ideas?

    Here is the what the code looks like, btw:

    if(isset($_POST['submit'])) {
        $to = ""; 
        $subject = "Subject";
        $name_field = $_POST['name'];
        $email_field = $_POST['email'];
        foreach($_POST['check'] as $value) {
            $check_msg .= "Checked: $value\n";
        $body = "From: $name_field\n E-Mail: $email_field\n";
        echo "Data has been submitted to $to!";
        mail($to, $subject, $body);
    } else {
        echo "try again!";

  2. #2
    You need to set your form action to the same page that you're on. Then you'll put that code at the top inside the body tags of your php file, though it may already by structured like that, I don't know. You can take out the echo if you want and just have it display the form again, or you can echo nothing. If you can show the whole file and maybe explain a bit better what you're trying to do I'd be happy to help further.

  3. #3


    I definitely appreciate you pointing me in the right direction!
    Most importantly, I got it working using your advice.
    I've only been using PHP for a couple of weeks, but I'm really excited to be figuring it out.
    Thanks again!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Home About Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012