Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Making forms (not forums)  (Read 12107 times)

0 Members and 1 Guest are viewing this topic.

Zylstra

    Topic Starter
  • Moderator


  • Hacker

  • The Techinator!
  • Thanked: 45
    • Yes
    • Technology News and Information
  • Certifications: List
  • Computer: Specs
  • Experience: Guru
  • OS: Windows 7
Making forms (not forums)
« on: March 31, 2006, 09:54:15 PM »
I have Dreamweaver, and I would like to know how to make it so a form send information to a specific email address. I have no idea whatsoever of how to do this.
« Last Edit: March 31, 2006, 11:50:55 PM by zylstra555 »

Flame

  • Moderator


  • Prodigy

  • Think, dream, see, be... Everything.
  • Thanked: 6
    • Yes
  • Certifications: List
  • Experience: Guru
  • OS: Other
Re: Making forms (not forums)
« Reply #1 on: April 01, 2006, 05:54:35 AM »
I had the same question a while ago. This will help you. Read the instructions carefully. http://www.webmaster-talk.com/php-forum/35929-feedback-form.html ... For other website questions, you might try http://www.webmaster-talk.com  :)

Flame

Zylstra

    Topic Starter
  • Moderator


  • Hacker

  • The Techinator!
  • Thanked: 45
    • Yes
    • Technology News and Information
  • Certifications: List
  • Computer: Specs
  • Experience: Guru
  • OS: Windows 7
Re: Making forms (not forums)
« Reply #2 on: April 01, 2006, 12:08:56 PM »
OK,
Looks simple and easy (not what I thought it would be)
I will mess around with that code and see if I can get it.
Thanks

Flame

  • Moderator


  • Prodigy

  • Think, dream, see, be... Everything.
  • Thanked: 6
    • Yes
  • Certifications: List
  • Experience: Guru
  • OS: Other
Re: Making forms (not forums)
« Reply #3 on: April 01, 2006, 01:05:55 PM »
Sure thing. Keep us posted on how you do. As usual, come back and see us if you have any more questions as well  ;)

Flame
« Last Edit: April 01, 2006, 01:06:24 PM by flame »

Zylstra

    Topic Starter
  • Moderator


  • Hacker

  • The Techinator!
  • Thanked: 45
    • Yes
    • Technology News and Information
  • Certifications: List
  • Computer: Specs
  • Experience: Guru
  • OS: Windows 7
Re: Making forms (not forums)
« Reply #4 on: April 01, 2006, 03:00:24 PM »
When I click "Send the Form" it goes the the Pagetwo.php, but gives me the code.

It shows this:

<?php

$body_of_message= $_POST['message']. "\n";
$body_of_message .= "Sent by " . $_POST['name'];
$subject= "Message from the feedback form";

if(mail("[email protected]",$subject,$body_of _message)) {
echo "Your message was sent.";
} else {
echo "There was a problem.";
};

?>


It does not send anything. What do I do to fix the problem?

Rob Pomeroy



    Prodigy

  • Systems Architect
  • Thanked: 124
    • Me
  • Experience: Expert
  • OS: Other
Re: Making forms (not forums)
« Reply #5 on: April 01, 2006, 10:00:25 PM »
It's easy enough to design the form, but then you need a program to process the data sent by the form.  In this case, the data is being sent to a PHP script.  If you don't have a PHP-enabled webserver, this will not do you any good.
Only able to visit the forums sporadically, sorry.

Geek & Dummy - honest news, reviews and howtos

Flame

  • Moderator


  • Prodigy

  • Think, dream, see, be... Everything.
  • Thanked: 6
    • Yes
  • Certifications: List
  • Experience: Guru
  • OS: Other
Re: Making forms (not forums)
« Reply #6 on: April 02, 2006, 08:06:16 AM »
Check into that. Who is your host? We need to make sure they support PHP... Good point Rob  :)

Flame

Franky

  • Guest
Re: Making forms (not forums)
« Reply #7 on: April 02, 2006, 08:43:39 AM »
Hey,

Well I'm in Information Technology and I have done a lot of dreamweaver and forms in my Web course. To send form information to an e-mail address, you have to include the following after your first or second heading in your code:

<form action="mailto: email_address?subject = Send" method="post" enctype="text/plain">

Some email servers will let you open the browser automatically when the button is pressed. Some you might not be able to. Also, depending on your e-mail configuration, you may receive warning dialog boxes or be given a chance to edit the e-mail message.

Hope it helps!

Mindwr@ck



    Rookie
    Re: Making forms (not forums)
    « Reply #8 on: April 20, 2006, 10:51:46 PM »
    Sometimes seeing code is better at helping you learn it. Here is a simple form that is commented so you can see what to change and what each section does. This example does require you to have a PHP enabled server. Hope this helps!

    Code: [Select]
    <?php
    echo "      <center>";

    //BEGIN PROCESSING EMAIL 
    if ($_POST['name']){

    //CHECK YO SEE IF REQUIED FIELDS ARE EMPTY      
          
    if(empty($_POST['name']) &#124;&#124; empty($_POST['email'])){

    //IF A REQUIRED FIELD IS EMPTY SHOW THIS TO USER
          
    echo "      <div class='plaintext'><br />Please fill out the form completly</div><br />";
          
          }

    //IF ALL FIELDS ARE FILLED OUT SEND THE MESSAGE INFORMATION
          
    else{
    $where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
    $message="Name: ".$name."
    Email: "
    .$email."
    Yahoo: "
    .$yahoo."
    MSN: "
    .$msn."
    Comments: "
    .$Comments."
    "
    ;
    $message stripslashes($message);

    //EDIT REQUIRED:::::::::::CHANGE [email protected] TO YOUR EMAIL ADDRESS
    //EDIT REQUIRED:::::::::::CHANGE FROM: YOUR WEBSITE TO FROM: <WHAT YOU WANT>
    mail("[email protected]","Contact Us Form Submitted",$message,"FROM: YOUR WEBSITE");
    //END PROCESSING EMAIL

    //BEGIN SHOWING WHAT THE USER SUBMITTED
    echo "      <div class='txtSession'>Thank you. You input this information.</div>";

    echo 
    "      <table width=75%>";

    echo 
    "      <tr>";
    echo 
    "      <td><div class='txtSession'>Name:</div></td>";
    echo 
    "      <td><div class='txtSession'>$name</div></td>";

    echo 
    "      </tr><tr>";

    echo 
    "      <td><div class='txtSession'>Email:</div></td>";
    echo 
    "      <td><div class='txtSession'>$email</div></td>";

    echo 
    "      </tr><tr>";

    echo 
    "      <td><div class='txtSession'>Yahoo:</div></td>";
    echo 
    "      <td><div class='txtSession'>$yahoo</div></td>";

    echo 
    "      </tr><tr>";

    echo 
    "      <td><div class='txtSession'>MSN:</div></td>";
    echo 
    "      <td><div class='txtSession'>$msn</div></td>";

    echo 
    "      </tr><tr>";

    echo 
    "      <td><div class='txtSession'>Comments:</div></td>";
    echo 
    "      <td><div class='txtSession'>$Comments</div></td>";

    echo 
    "      </tr>";

    echo 
    "      </table>";
    //END SHOWING WHAT THE USER SUBMITTED
    }
    }

    //BEGIN THE CONTACT FORM
    echo "      <br/><br/>";

    echo 
    "      <form method='post' action='contactus.php' target='_self'>";

    echo 
    "      <table width='75%' border='0'>";

    echo 
    "      <tr>";

    echo 
    "      <td><div class='txtSession'>Name *</div></td>";
    echo 
    "      <td><input type='text' size='30' name='name' class='textbox'></td>";

    echo 
    "      </tr><tr>";

    echo 
    "      <td><div class='txtSession'>Email *</div></td>";
    echo 
    "      <td><input type='text' size='30' name='email' class='textbox'></td>";

    echo 
    "      </tr><tr>";

    echo 
    "      <td><div class='txtSession'>Yahoo</div></td>";
    echo 
    "      <td><input type='text' size='30' name='yahoo' class='textbox'></td>";

    echo 
    "      </tr><tr>";

    echo 
    "      <td><div class='txtSession'>MSN</div></td>";
    echo 
    "      <td><input type='text' size='30' name='msn' class='textbox'></td>";

    echo 
    "      </tr><tr>";

    echo 
    "      <td><div class='txtSession'>Comments</div></td>";
    echo 
    "      <td>&nbsp;</td>";

    echo 
    "      </tr><tr>";

    echo 
    "      <td colspan='2'><textarea cols='50' name='Comments' rows='5' class='textbox'>Give us your feedback, good or bad!</textarea></td>";

    echo 
    "      </tr>";

    echo 
    "      </table>";
         
    echo 
    "      <div align='center'><input type='submit' value='Submit Form'>  <input type='reset' value='Clear Form'></div>";

    echo 
    "      </form>";
    //END THE CONTACT FORM
    echo "      </center>";
    ?>
    « Last Edit: April 20, 2006, 10:53:27 PM by Mindwr@ck »
    Mindwr@ck

    Zylstra

      Topic Starter
    • Moderator


    • Hacker

    • The Techinator!
    • Thanked: 45
      • Yes
      • Technology News and Information
    • Certifications: List
    • Computer: Specs
    • Experience: Guru
    • OS: Windows 7
    Re: Making forms (not forums)
    « Reply #9 on: June 22, 2006, 02:42:41 PM »
    (later responce, better server, more fun!)
    OK, now I get this:
    Parse error: syntax error, unexpected T_STRING in /home/jessez/public_html/password_content/process_request.php on line 39

    Rob Pomeroy



      Prodigy

    • Systems Architect
    • Thanked: 124
      • Me
    • Experience: Expert
    • OS: Other
    Re: Making forms (not forums)
    « Reply #10 on: June 22, 2006, 03:11:39 PM »
    Please post the section of code that includes that line.  I'll need to see the line immediately above it for debugging purposes.  Please clearly indicate which is the correct line, 'cause I ain't gonna count it for you.  ;)
    « Last Edit: June 22, 2006, 03:12:01 PM by robpomeroy »
    Only able to visit the forums sporadically, sorry.

    Geek & Dummy - honest news, reviews and howtos

    Zylstra

      Topic Starter
    • Moderator


    • Hacker

    • The Techinator!
    • Thanked: 45
      • Yes
      • Technology News and Information
    • Certifications: List
    • Computer: Specs
    • Experience: Guru
    • OS: Windows 7
    Re: Making forms (not forums)
    « Reply #11 on: June 22, 2006, 06:30:43 PM »
    Ok, I didn't know that I needed the same code for this. Since all of this, the file has been modified.
    The new error code is this:
    Parse error: syntax error, unexpected T_STRING in /home/jessez/public_html/password_content/process_request.php on line 8

    Here's the actual code, with lines and numbers.
    Code: [Select]
    1  |<p>
    2  |  <?php
    3  
    &#124;
    4  &#124;$body_of_message= $_POST['message']. "\n";
    5  &#124;$body_of_message .= "Sent by " . $_POST['name'];
    6  &#124;$subject= "Message from the feedback form";
    7  &#124;
    8  &#124;if(mail("[email protected]",$subject,$body_of _message)) {
    9  &#124;echo "Your message was sent.";
    10&#124;} else {
    11&#124;echo "There was a problem.";
    12&#124;};
    13&#124;
    14&#124;?>

    15|</p>
    16|

    And just for everyone's entertainment, a screenshot of this is included
    « Last Edit: June 22, 2006, 06:34:05 PM by zylstra555 »

    Rob Pomeroy



      Prodigy

    • Systems Architect
    • Thanked: 124
      • Me
    • Experience: Expert
    • OS: Other
    Re: Making forms (not forums)
    « Reply #12 on: June 23, 2006, 02:33:46 AM »
    Got it.  It was very hard to spot!

    On the line
    if(mail("[email protected]",$subject,$body_of _message)) {
    you have a space in the middle of the variable name, "$body_of _message", before the second underscore.  Delete it.  :)
    « Last Edit: June 23, 2006, 02:34:16 AM by robpomeroy »
    Only able to visit the forums sporadically, sorry.

    Geek & Dummy - honest news, reviews and howtos

    Zylstra

      Topic Starter
    • Moderator


    • Hacker

    • The Techinator!
    • Thanked: 45
      • Yes
      • Technology News and Information
    • Certifications: List
    • Computer: Specs
    • Experience: Guru
    • OS: Windows 7
    Re: Making forms (not forums)
    « Reply #13 on: June 23, 2006, 02:01:31 PM »
    "Your message was sent."
    unless there's a hidden side to that message, everything is working. Thanks!

    But that wasn't the only problem, the email address was wrong. But I fixed that to.

    All seems to be well, now to see if it sends understandably.

    Edit:
    oh great.
    All I see in the message is this:

    From [email protected] Fri Jun 23 15:00:22 2006
    Return-path: <[email protected]>
    Envelope-to: [email protected]
    Delivery-date: Fri, 23 Jun 2006 15:00:22 -0500
    Received: from nobody by orbit.serverz.org with local (Exim 4.52)
        id 1FtrpF-0004w3-Rn
        for [email protected]; Fri, 23 Jun 2006 15:00:21 -0500
    To: [email protected]
    Subject: Message from the feedback form
    Message-Id: <[email protected]>
    From: Nobody <[email protected]>
    Date: Fri, 23 Jun 2006 15:00:21 -0500
    Status: R  Simple headers  

    Sent by
     
    « Last Edit: June 23, 2006, 02:03:14 PM by zylstra555 »

    Rob Pomeroy



      Prodigy

    • Systems Architect
    • Thanked: 124
      • Me
    • Experience: Expert
    • OS: Other
    Re: Making forms (not forums)
    « Reply #14 on: June 24, 2006, 12:32:51 AM »
    Are you sure that POST variables are reaching this form?  You can test by echoing them within your script (commenting out the mail section until you have verified that part is working.
    Only able to visit the forums sporadically, sorry.

    Geek & Dummy - honest news, reviews and howtos