www.webdeveloper.com
Results 1 to 13 of 13

Thread: My Contact Page

Hybrid View

  1. #1
    Join Date
    May 2012
    Location
    Hays, KS
    Posts
    24

    Question My Contact Page

    Send Contact Information to My Email

    Hi everyone! Right now, I'm working on my Contact page, for my personal website.

    This is what it looks like.
    ScreenShot2012-11-28at33648AM.png

    Code:
     <form id="contact" name="contact" method="post" action="">
        <p>
          <label for="name">Name</label>
        </p>
        <p>
          <input type="text" name="name" id="name" />
        </p>
        <p>
          <label for="email">Email</label>
        </p>
        <p>
          <input type="text" name="email" id="email" />
        </p>
        <p>What is the matter of this email? </p>
        <table width="200" id="radio">
          <tr>
            <td><label>
              <input type="radio" name="matter" value="comment" id="matter_0" />
            Comment</label></td>
          </tr>
          <tr>
            <td><label>
              <input type="radio" name="matter" value="question" id="matter_1" />
            Question</label></td>
          </tr>
          <tr>
            <td><label>
              <input type="radio" name="matter" value="request" id="matter_2" />
            Request</label></td>
          </tr>
        </table>
        <p>
          <label for="subject">Subject</label>
        </p>
        <p>
          <input type="text" name="subject" id="subject" />
        </p>
        <p>
          <label for="message">Text</label>
        </p>
        <p>
          <textarea name="message" id="message" cols="80" rows="10"></textarea>
        </p>
        <p>
         <input type="submit" name="submit" id="submit" value="Submit" />
          <input type="reset" name="clear" id="clear" value="Clear" />
        </p>
        <p>&nbsp;</p>
      </form>
    As you can see, I have a total of 5 requests. I want all 5 of them emailed to me. Obviously, the sender is handled by my web-hosting server, and the message/subject are simple, but I am unsure on how to get the sender's email and name included in the message.

    To anyone who can help, that would be greatly appreciated.
    Last edited by Tibneo; 11-28-2012 at 04:48 AM.

  2. #2
    Join Date
    Nov 2006
    Location
    Oakland
    Posts
    500
    It's more likely the fields name you use in your form (email, name) do not match what the server-side script is expecting. You can generally just look at the server-side script to get that information. Otherwise the web hosting company should provide that info somewhere in the help section.

  3. #3
    Join Date
    Aug 2012
    Posts
    155
    What is the code for generating the email?

  4. #4
    Join Date
    May 2012
    Location
    Hays, KS
    Posts
    24
    Here's the code for generating the email.

    Code:
    <?php 
    $ToEmail = 'tibneo@tibneo.hostoi.com'; 
    $EmailSubject = 'Site contact form'; 
    $mailheader = "From: ".$_POST["email"]."\r\n"; 
    $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; 
    $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
    $MESSAGE_BODY = "Name: ".$_POST["name"].""; 
    $MESSAGE_BODY .= "Email: ".$_POST["email"].""; 
    $MESSAGE_BODY .= "Message: ".nl2br($_POST["message"]).""; 
    mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); 
    ?>
    <form action="contact.php" method="post"> 
    <p>Please leave your full name, email, and your comment. Be sure that it is clear what your intention is in your email. I check my email periodically, so I intend to get back to you right away. Thanks.</p>
    <p>- Tibneo</p>
    <table width="387" height="239" border="0" cellpadding="0" cellspacing="2"> 
    <tr> 
    <td>Your name:</td> 
    </tr> 
    <tr>
      <td><input name="name" type="text" id="name" size="32" /></td>
      </tr>
    <tr>
      <td>&nbsp;</td>
    </tr>
    <tr> 
    <td>Email address:</td> 
    </tr> 
    <tr>
      <td><input name="email" type="text" id="email" size="32" /></td>
      </tr>
    <tr>
    </tr> 
    <tr>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>Message:</td>
    </tr>
    <tr>
      <td><textarea name="message" cols="50" rows="5" id="message" class="bodytext"></textarea></td>
      </tr>
    <tr>
      <td></td>
    </tr>
    <tr> 
    <td><input type="submit" name="submit" value="Submit" id="submit">  <input type="reset" name="clear" id="clear" value="Clear" /></td> 
    </tr> 
    </table>
      </form>
    right now i'm trying to get the code to work. whenever i receive emails, they arrive like this.
    Screen Shot 2012-12-07 at 9.26.57 AM.png

    I want to format this to where it looks like this:

    Name: ________

    Subject: ____________

    Message: ___________________
    ____________________________
    ____________________________


    I'm new to PHP coding, so I was hoping someone could help me out here.
    Last edited by Tibneo; 12-07-2012 at 10:28 AM.

  5. #5
    Join Date
    Aug 2012
    Posts
    155
    Right, I understand your problem now (it is not what I thought your problem was from the first post). All you need to do is include \n at the end of each line of your message body
    PHP Code:
    $name $_POST["name"];
    $email $_POST["email"];
    $message nl2br($_POST["message"]);

    $MESSAGE_BODY "Name: $name\n"
    $MESSAGE_BODY .= "Email: $email\n"
    $MESSAGE_BODY .= "Message: $message\n"
    You can put more in if you want more of a gap, for example \n\n
    Last edited by simplypixie; 12-07-2012 at 02:16 PM.

  6. #6
    Join Date
    May 2012
    Location
    Hays, KS
    Posts
    24
    what if i wanted a break rather than just spacing? thanks.

    also it seems like every time i hit refresh, i get an email and its blank. but the submit button does not work either.
    i know that i have some excess code. can you tell me which of this i can rid, and/or compress? thanks again.

    Code:
    <?php 
    $ToEmail = 'tibneo@tibneo.hostoi.com'; 
    $EmailSubject = 'Contact from tibneo.hostoi.com'; 
    $mailheader = "From: ".$_POST["email"]."\r\n"; 
    $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; 
    $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
    
    $name = $_POST["name"];
    $email = $_POST["email"];
    $message = nl2br($_POST["message"]);
    
    $MESSAGE_BODY = "Name: $name\n"; 
    $MESSAGE_BODY .= "Email: $email\n"; 
    $MESSAGE_BODY .= "Message: $message\n";
    mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); 
    ?>
    Last edited by Tibneo; 12-08-2012 at 06:17 PM.

  7. #7
    Join Date
    Aug 2012
    Posts
    155
    \n gives you a line break just like <br> so that is what you need.

    With regard to why your form isn't submitting, I have no idea without seeing your form code and any other PHP you have that deals with the posted form data (there is nothing in your code posted above that can be removed and there is no excess).

  8. #8
    Join Date
    May 2012
    Location
    Hays, KS
    Posts
    24
    Maybe i'll need to be a bit more specific.

    Okay. I have my main page "index.html" in my contacts folder. index.html has the 'design' part of my contact page.

    Code:
    <form action="thank-you.html" method="post">
        <p id="p">Please leave your full name, email, and your comment. Be sure that it is clear what your intention is in your email. I check my email periodically, so I intend to get back to you right away. Thanks.</p>
        <p>- Tibneo</p>
        <table width="387" height="239" border="0" cellpadding="0" cellspacing="2">
          <tr>
            <td>Your name:</td>
          </tr>
          <tr>
            <td><input name="name" type="text" id="name" size="32" /></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>Email address:</td>
          </tr>
          <tr>
            <td><input name="email" type="text" id="email" size="32" /></td>
          </tr>
          <tr></tr>
          <tr>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>Message:</td>
          </tr>
          <tr>
            <td><textarea name="message" cols="50" rows="5" id="message" class="bodytext"></textarea></td>
          </tr>
          <tr>
            <td></td>
          </tr>
          <tr>
            <td><input type="submit" name="submit" value="Submit" id="submit" />
              <input type="reset" name="clear" id="clear" value="Clear" /></td>
          </tr>
        </table>
      </form>
    This is the form, the input/textarea. pretty much, this is what the viewer sees.

    now.

    before, i had everything in a single .php file, including the input and textarea. and i just had a single iframe on the main (index.html) page. and that clearly wasn't working.

    could i be doing something wrong? where do i go from here?

  9. #9
    Join Date
    Aug 2012
    Posts
    155
    Well the first thing I see is that you are trying to submit your form to an html page when it should be a php page so change your file name and form action to thank-you.php
    HTML Code:
    <form action="thank-you.php" method="post">

  10. #10
    Join Date
    May 2012
    Location
    Hays, KS
    Posts
    24
    Quote Originally Posted by simplypixie View Post
    Well the first thing I see is that you are trying to submit your form to an html page when it should be a php page so change your file name and form action to thank-you.php
    HTML Code:
    <form action="thank-you.php" method="post">
    done. let me know if you see anything else.

  11. #11
    Join Date
    Aug 2012
    Posts
    155
    Is it working now then?

  12. #12
    Join Date
    May 2012
    Location
    Hays, KS
    Posts
    24
    Quote Originally Posted by simplypixie View Post
    Is it working now then?
    yes! yes it is! thanks a lot! much appreciated!

  13. #13
    Join Date
    Aug 2012
    Posts
    155
    Oh good, wan't sure from the previous reply

Thread Information

Users Browsing this Thread

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

Tags for this Thread

Posting Permissions

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



Recent Articles