I'm trying to figure out the glitch in modifying this simple php email form below.

What I am trying to do is assign the form values to the php variables, but with a bit of a twist.

In the $message content, I would like to combine 'name' and 'email' (address) from the form to also be the 1st part of the $message before the users message. Kind of like:

(Message Area between ====)

From: Joe Blow

E-mail: joe@blow.com

...blank line here...
Users message content here from the textarea box
...
...

etc.

I'm also missing something in the Form 'action' part but not sure what to use.

Tnx for any help.

<?php
?>
<html>
<head>
<title>E-mail Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<FORM method="POST">
SIMPLE E-MAIL FORM:<br><br>
Name:<br> <input name="name" type="text" size="50"><br>
E-mail:<br> <input name="email" type="text" size="50"><br>
Subject:<br> <input name="subject" type="text" size="50"><br>
Message:<br> <textarea name="message" cols="50" rows="10" type="text"></textarea><br><br>

<?php

$email ="destination@address.com": 
$subject ="This is the Subject Text": 
$message ="Email message content here.": 
$replyto ="senderemail@address.com": 
// send email 
mail ("$email","$subject","$message","$replyto"); 
exit; 

?> 
<input name="submit" type="button" value="Send Mail">
</FORM>
</body>
</html>
<?php
?
    <html> 
    <head> 
    <title>E-mail Form</title> 
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
    </head> 
    <body> 
    <FORM method="POST" action = "URL OF OF THE PAGE TO SEND THE EMAIL PAGE BELOW"> 
    SIMPLE E-MAIL FORM:<br><br> 
    Name:<br> <input name="name" type="text" size="50"><br> 
    E-mail:<br> <input name="email" type="text" size="50"><br> 
    Subject:<br> <input name="subject" type="text" size="50"><br> 
    Message:<br> <textarea name="message" cols="50" rows="10" type="text"></textarea>
    
    <input name="submit" type="button" value="Send Mail"> 
    </FORM>
    </body> 
    </html> 
    

    NEW PAGE (.PHP)

    <?php 
    
    $email = $_POST["email"];
    $name = $_POST["name"];
    $subject = $_POST["subject"];
    $message1 = $_POST["message"];
    $replyto = $_POST["email"]'; //THIS MAY NOT BE HOW YOU WANT BUT YOU CAN CHANGE IT...
    
    $message <<HERE
    ====<br>
    From: $name<br>
    E-Mail: $email<br>
    ----------------------------<br>
    <br>
    $message1
    HERE;
    
    $messageHeader = NULL;
    
    $messageHeader . "From: $email" . "Reply-To: $email" . "X-Mailer: PHP/" . phpinfo();
    
    // send email 
    mail ($email,$subject,$message,$messageHeader);  
    
    
    ?> 
    <META HTTP-EQUIV="refresh" CONTENT="15 (AMMOUNT OF SECONDS UNTIL FOWARD; URL="URL TO SEND PAGE TO"> //NEEDS TO BE CHANGED
    
    

    HTML Email will be requried... i hope this answers your question...

    If you dont know anything here look in the PHP manule.. (you can get it at: www.php.net)

    Andrew

      Andrew:

      Thanks for your reply.

      I'm confused about 2 things, however.

      1. How can $email AND $replyto both be: $_POST["email"]?

      2. Is there anyway to use the php mail function instead of HTML mail???

      Thanks.

        Hey,

        1. You do not have a Field for the Reply-To email so I did just the one email feld... This would be something you would need to change or add to how you want it like adding in the <FORM> tag:

        Reply-To Email Address:<INPUT type = "text" name = "replyto">

        and in the PHP variable declaration add:

        $replyto = $_POST["replyto"];

        1. You are using the PHP mail() funtion... I do not even believe there is a HTML function named MAIL or is there even functions just tags...

        Anyways...,

        Anymore question I would be happy to answer...

        Andrew

          6 days later

          Thanks, Andrew. I made some changes but it is still kinda whacked out...and displays my ISP's PHP configuration stuff on the page at the end.

          Actually, the email is NOT supposed to go to a webpage, but FROM the 'reply-to' person's address TO 'my' email address...so I'm thinking the 2nd page now is unnecessary?

          Here's where I am at:

          <?php
          ?>
          <html>  
          <head>
          <title>E-mail Form</title>
          <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
          </head>
          <body>
          <FORM method="POST" action = "http://mydomainURL - the page2 file">
          SIMPLE E-MAIL FORM:<br><br>
          Name:<br> <input name="name" type="text" size="50"><br>
          E-mail:<br> <input name="email" type="text" size="50"><br> Reply-To Email Address:<br><INPUT name"replyto" type="text" size="50"><br> Subject:<br> <input name="subject" type="text" size="50"><br>
          Message:<br> <textarea name="message" cols="50" rows="10" type="text"></textarea><br><br> <input name="submit" type="submit" value="Send Mail">
          </FORM> </body>
          </html> <?php ?
          <?php  
          $email = $_POST["email"]; $name = $_POST["name"]; $replyto = $_POST["replyto"];
          $subject = $_POST["subject"]; $message1 = $_POST["message"]; $message = "Test message here====<br>"; echo "From: "."$name<br>"; echo "E-Mail: "."$email<br>"; echo "----------------------------<br>"; echo "<br> "; echo $message1; $messageHeader = NULL; $messageHeader . "From: $email" . "Reply-To: $email" . "X-Mailer: PHP/" . phpinfo(); // send email mail ($email,$subject,$message,$messageHeader); ?> <html> <head> <title></title> </head> <body> <META HTTP-EQUIV="refresh" CONTENT="15 (AMOUNT OF SECONDS UNTIL FOWARD; URL="mydomainURLhere"> </body> </html> <?php ?>

          In any event, it is still not formatting correctly. Umh, couldn't the basic form & emailing part be combined into just one page?

          Thanks.

            <?php
            if ($submit=="Send Mail")
            {
            $email = $_POST["email"]; 
            $name = $_POST["name"];
            $replyto = $_POST["replyto"];  
            $subject = $_POST["subject"]; $message1 = $_POST["message"]; $message = "Test message here====<br>"; echo "From: "."$name<br>"; echo "E-Mail: "."$email<br>"; echo "----------------------------<br>"; echo "<br> "; echo $message1; $messageHeader = NULL; $messageHeader . "From: $email" . "Reply-To: $email" . "X-Mailer: PHP/" . phpinfo(); // send email mail ($email,$subject,$message,$messageHeader);
            } ?> <html>
            <head>
            <title>E-mail Form</title>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
            </head>
            <body>
            <FORM method="POST" action = "http://urlof this page">
            SIMPLE E-MAIL FORM:<br><br>
            Name:<br> <input name="name" type="text" size="50"><br>
            E-mail:<br> <input name="email" type="text" size="50"><br> Reply-To Email Address:<br><INPUT name"replyto" type="text" size="50"><br> Subject:<br> <input name="subject" type="text" size="50"><br>
            Message:<br> <textarea name="message" cols="50" rows="10" type="text"></textarea><br><br> <input name="submit" type="submit" value="Send Mail">
            </FORM> </body>
            </html>

            If i have write all correct...this let you to use only one page........

              a month later

              okuto1973...

              Dunno how I misplaced this post, so sorry for the long overdue "thanks".

                Write a Reply...