What To Do After Making A Submit Button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • FlaPnthrsPunk
    New Member
    • Feb 2007
    • 3

    What To Do After Making A Submit Button

    Hi all, this is my first time ever using PHP, and I am still very new to programming in general. I'm doing an assignment for my Media E-Commerce class where the code for a survey is all provided. It first asks the user to provide their first and last name in two text boxes, and then has three separate tables where the user can choose a rating from 1 to 5 in radio buttons. Then, once they are done, they click the submit button. From there, a new table is supposed to come up I'm assuming on a new page that is separated into two columns (rating and count) with the answers that the user submitted in the survey, which is basically my assignment to complete.

    I've been reading many tutorials and forums all day trying to figure this out, but since I have very limited programming knowledge in general, I'm having quite a hard time with this even though I've seen similar posts where responses say this type of thing is not difficult at all to complete. However, I still cannot figure it out. Any help given will be much appreciated. Thanks a lot.

    This is the code of the survey
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body bgcolor="#0000CC" text="#CCCCCC">
    <div align="center"><strong><font size="6" face="MS Sans Serif">The University 
      of Bithlo </font></strong><font size="6" face="MS Sans Serif"></h1> </font></div>
    <form action="test.php" method="post" name="bithlosurvey" id="bithlosurvey">
    </form>
    <form name="form1" method="post" action="">
      <p align="center"> <font face="MS Sans Serif">
        <input name="firstname" id="firstname" type="text">
        Student's First Name</font></p>
      <p align="center"> <font face="MS Sans Serif">
        <input name="lastname" id="lastname" type="text">
        Student's Last Name </font></p>
    </form>
    <p align="left"><font face="MS Sans Serif">Please use a scale of 1 (first-rate; 
      great; awesome) through 5 (really really really really really terrible) to answer 
      each of these questions. </font></p>
    <p align="center"><font face="MS Sans Serif"><strong>Course 1: Removing Ash Trays 
      from 1991 Ford Tauruses</strong></font></p>
    <p align="center"><font face="MS Sans Serif"><strong>Instructor: Roy Rogers</strong></font></p>
    <div align="center"> 
      <table border="4" cellpadding="4" cellspacing="0">
        <tbody>
          <tr> 
            <th scope="col">&nbsp;</th>
            <th scope="col"><font face="MS Sans Serif">Great</font></th>
            <th scope="col"><font face="MS Sans Serif">Good</font></th>
            <th scope="col"><font face="MS Sans Serif">OK</font></th>
            <th scope="col"><font face="MS Sans Serif">So-So</font></th>
            <th scope="col"><font face="MS Sans Serif">Sucks Lemons </font></th>
          </tr>
          <tr> 
            <td><font face="MS Sans Serif">Quality of Lectures </font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply1.1" value="1" type="radio">
              1</font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply1.1" value="2" type="radio">
              2 </font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply1.1" value="3" type="radio">
              3</font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply1.1" value="4" type="radio">
              4</font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply1.1" value="5" type="radio">
              5</font></td>
          </tr>
          <tr> 
            <td><p><font face="MS Sans Serif">Quality of Handouts</font></p></td>
            <td> <font face="MS Sans Serif">
              <input name="reply1.2" value="1" type="radio">
              1</font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply1.2" value="2" type="radio">
              2 </font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply1.2" value="3" type="radio">
              3</font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply1.2" value="4" type="radio">
              4</font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply1.2" value="5" type="radio">
              5</font></td>
          </tr>
        </tbody>
      </table>
    </div>
    <p align="center">&nbsp;</p>
    <p align="center"><font face="MS Sans Serif"><strong>Course 2: Removing Rear Bumpers 
      from 1987 Chevy S-10s </strong></font></p>
    <p align="center"><font face="MS Sans Serif"><strong>Instructor: Gene Autry </strong></font></p>
    <div align="center"> 
      <table border="4" cellpadding="4" cellspacing="0">
        <tbody>
          <tr> 
            <th scope="col">&nbsp;</th>
            <th scope="col"><font face="MS Sans Serif">Great</font></th>
            <th scope="col"><font face="MS Sans Serif">Good</font></th>
            <th scope="col"><font face="MS Sans Serif">OK</font></th>
            <th scope="col"><font face="MS Sans Serif">So-So</font></th>
            <th scope="col"><font face="MS Sans Serif">Sucks Lemons </font></th>
          </tr>
          <tr> 
            <td><font face="MS Sans Serif">Quality of Lectures </font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply2.1" value="1" type="radio">
              1</font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply2.1" value="2" type="radio">
              2 </font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply2.1" value="3" type="radio">
              3</font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply2.1" value="4" type="radio">
              4</font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply2.1" value="5" type="radio">
              5</font></td>
          </tr>
          <tr> 
            <td><p><font face="MS Sans Serif">Quality of Handouts</font></p></td>
            <td> <font face="MS Sans Serif">
              <input name="reply2.2" value="1" type="radio">
              1</font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply2.2" value="2" type="radio">
              2 </font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply2.2" value="3" type="radio">
              3</font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply2.2" value="4" type="radio">
              4</font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply2.2" value="5" type="radio">
              5</font></td>
          </tr>
        </tbody>
      </table>
    </div>
    <p align="center">&nbsp;</p>
    <p align="center"><font face="MS Sans Serif"><strong>Course 3: Stealing Customer's 
      Far-Side Hubcaps to Sell to Him </strong></font></p>
    <p align="center"><font face="MS Sans Serif"><strong>Instructor: Lash Larue </strong></font></p>
    <div align="center"> 
      <table border="4" cellpadding="4" cellspacing="0">
        <tbody>
          <tr> 
            <th scope="col">&nbsp;</th>
            <th scope="col"><font face="MS Sans Serif">Great</font></th>
            <th scope="col"><font face="MS Sans Serif">Good</font></th>
            <th scope="col"><font face="MS Sans Serif">OK</font></th>
            <th scope="col"><font face="MS Sans Serif">So-So</font></th>
            <th scope="col"><font face="MS Sans Serif">Sucks Lemons </font></th>
          </tr>
          <tr> 
            <td><font face="MS Sans Serif">Quality of Lectures </font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply3.1" value="1" type="radio">
              1</font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply3.1" value="2" type="radio">
              2 </font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply3.1" value="3" type="radio">
              3</font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply3.1" value="4" type="radio">
              4</font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply3.1" value="5" type="radio">
              5</font></td>
          </tr>
          <tr> 
            <td><p><font face="MS Sans Serif">Quality of Handouts</font></p></td>
            <td> <font face="MS Sans Serif">
              <input name="reply3.2" value="1" type="radio">
              1</font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply3.2" value="2" type="radio">
              2 </font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply3.2" value="3" type="radio">
              3</font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply3.2" value="4" type="radio">
              4</font></td>
            <td> <font face="MS Sans Serif">
              <input name="reply3.2" value="5" type="radio">
              5</font></td>
          </tr>
        </tbody>
      </table>
    </div>
    <form name="form2" method="post" action="">
      <div align="center"> <font face="MS Sans Serif">
        <input name="Submit" value="Submit" type="submit">
        </font></div>
    </form>
    Last edited by ronverdonk; Feb 10 '07, 12:20 PM. Reason: code within tags
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Before you post any further in this forum, read the Posting Guidelines, especially the part about enclosing your code within code or php tags!!!

    Moderator

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      Hi.

      This is a code that uses html forms and php to send an email.
      I thought it might help you do your assignment.

      Note. Both html and php should be in the same .php file
      [HTML]<!--
      The Form, if you have your php code in another file
      you should put the url in the action field
      of the form element.
      I leave it emtpy because I want it to post to
      the same file it is in.
      -->
      <form name="MyForm" method="post" action="">
      <table width="400" border="0" align="center" cellpadding="2" cellspacing="0" >
      <tr>
      <td width="50%" align="right">F rom : </td>
      <td><input name="From" type="text" size="30" /></td>
      </tr>
      <tr>
      <td align="right">T o : </td>
      <td><input name="To" type="text" size="30" /></td>
      </tr>
      <tr>
      <td align="right">S ubject : </td>
      <td><input name="Subject" type="text" size="30" /></td>
      </tr>
      <tr>
      <td align="right">M essage : </td>
      <td><textarea name="Message" cols="30" rows="7"></textarea></td>
      </tr>
      <tr>
      <td colspan="2" align="center">
      <!--
      The submit button, this is the value I use to
      check if the form has been submitted in the php code
      -->
      <input name="MySubmit" type="submit" value="Send" />
      </td>
      </tr>
      </table>
      </form>
      [/HTML]
      [PHP]
      <?php
      // Find if the form has been posted
      // by checking if the button 'MySubmit'
      // has a value.
      if(isset($_POST['MySubmit']))
      {
      // Get the other information
      // using the $_POST array
      // to read the information you
      // posted in your form
      $From = $_POST['From'];
      $To = $_POST['To'];
      $Subject = $_POST['Subject'];
      $Msg = $_POST['Message'];

      // Set up Email headers
      $headers = 'From: '. $From;

      // Send email and check if it was sent
      if(mail($To, $Subject, $Msg, $headers))
      {
      echo "<p align='center'> Your email has been sent </p>";
      }
      else
      {
      echo "<p align='center'> An error accured while sending your email </p>";
      }
      }
      ?>[/PHP]

      Comment

      • FlaPnthrsPunk
        New Member
        • Feb 2007
        • 3

        #4
        Originally posted by ronverdonk
        Before you post any further in this forum, read the Posting Guidelines, especially the part about enclosing your code within code or php tags!!!

        Moderator
        Sorry about that. I will read the guidelines now. I wasn't even aware you could do that with the code, but thanks for editing for me anyway.

        Comment

        • FlaPnthrsPunk
          New Member
          • Feb 2007
          • 3

          #5
          Originally posted by Atli
          Hi.

          This is a code that uses html forms and php to send an email.
          I thought it might help you do your assignment.
          Thank you very much. I have a feeling this example will help me a lot, not just on this assignment, but in PHP overall in general.

          Comment

          Working...