Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Help needed in PHP ! Thanx Part 1 Creating the form You\'ve been asked to whip u

ID: 3598132 • Letter: H

Question

Help needed in PHP ! Thanx

Part 1 Creating the form You've been asked to whip up a prototype HTML form in a document called survey.php to collect the following info (remember your target audience when labeling your fields!): First and last name . Year of birth Current school year (e.g. 7-12) Number of siblings Bedtime and when they wake up Approximate time spent on homework per day Time spent watching TV/DVD etc. per day Time spent using computer or games console per day Time spent with family per day Time spent with friends per day You do not necessarily need to make your form pretty or worry about input validation for the prototype, but it certainly needs to be easy to use.

Explanation / Answer

survey.php


<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
      
      
<center>
    <center>
        <form method="post" action="process.php" >
      
           <table border="0" height="85%" width="40%" align="center" cellpadding="5" cellspacing="0">
    
       <br></br>
       <br></br>
       <br></br>
       <br></br>
      <th align="center"> data posting form</th>
    
          <tr>
              <td ><label>firstname:</label></td>
              <td align="left">
        
              <input required type="text" name="fname" color="white" length="10"/>
        </td></tr>
      <tr>
              <td ><label>lastname:</label></td>
              <td align="left">
        
              <input required type="text" name="lname" color="white" length="10"/>
        </td></tr>
        
      <tr>
              <td><label>Year of Birth:</label></td>
              <td align="left">
        
                  <input required type="date " name="dob" color="white"/>&nbsp;&nbsp;&nbsp;yyyy-mm-dd</td>
        </tr>
      
          <tr>
              <td ><label>school year :( 7 to 12)</label></td>
              <td align="left">
        
              <input required type="text" name="sy" color="white" length="10"/>
        </td></tr>
         <tr>
              <td ><label>Number of siblings</label></td>
              <td align="left">
        
              <input required type="text" name="nos" color="white" length="10"/>
        </td></tr>
          <tr>
              <td ><label>woke up at</label></td>
              <td align="left">
        
              <input required type="text" name="wut" color="white" length="10"/>
        </td></tr>
           <tr>
              <td ><label>time spent on home work per day</label></td>
              <td align="left">
        
              <input required type="text" name="tsw" color="white" length="10"/>
        </td></tr>
        
           <tr>
              <td ><label>time spent for tv/dvd per day</label></td>
              <td align="left">
        
              <input required type="text" name="tst" color="white" length="10"/>
        </td></tr>
         
           <tr>
              <td ><label>time spent for computer games per day</label></td>
              <td align="left">
        
              <input required type="text" name="tsg" color="white" length="10"/>
        </td></tr>
         
         
           <tr>
              <td ><label>time spent with family per day</label></td>
              <td align="left">
        
              <input required type="text" name="tsf" color="white" length="10"/>
        </td></tr>
           <tr>
              <td ><label>time spent with friends per day</label></td>
              <td align="left">
        
              <input required type="text" name="tsff" color="white" length="10"/>
        </td></tr>
      
      
           
             
               
           <tr>
<td height="20" align="right"><input type="submit" value="Post" id="sub"></td>
<td height="20" align="left"><input type="reset" value="Reset"></td></tr>
</tr>
             </form>
      
        </body>
        </html>

process.php:

<?php

<?php


  

   $fname=$_REQUEST['fname'];

   $lname=$_REQUEST['lname'];
   $dob=$_REQUEST['dob'];
   $sy=$_REQUEST['sy'];
   $nos=$_REQUEST['nos'];
   $wut=$_REQUEST['wut'];
   $tsw=$_REQUEST['tsw'];
   $tst=$_REQUEST['tst'];
   $tsg=$_REQUEST['tsg'];
   $tsf=$_REQUEST['tsf'];
   $tsff=$_REQUEST['tsff'];

   echo '"Great!Thanks'.$fname." ".$lname.'for responding to our survey"'.'<br/>';
   echo "Name".$fname." ".$lname.'<br/>';
      echo "dob".$dob.'<br/>';

      echo "school year".$sy.'<br/>';
      echo "Number of Siblings".$nos.'<br/>';
    
      echo "Changes".'<br/>';
      echo "You receive an email from P&C Committee asking that once you have this working
          that you modify the response message to student to show:".'<br/';
    
        $y=365;
      echo "Based on the information you have entered ,you will spend".'<br/>';
      $x=$tst*$y;
      echo " $x hours per year watching TV or movies ";
  
      $x=(int)$tsw*$y;
            
    $a=(int)$tsg*$y;
     echo " $x hours per year doing homework".'<br/>';

   
     echo " $a hours per year in front of a TV or computer screen".'<br/>';
     $b=(int)($tsf+$tsff);
     $b=$b*$y;
     echo " $b hours per year with friends and family".'<br/>';
      $c=(int)$sy;
     $c=(12-$c);
      echo " $c years you have left at school".'<br/>';
      $c=(12-(int)$sy)*($y*(int)$tsw);
      echo " $c hours will spent for doing homework".'<br/>';
      $e=(12-(int)$sy)*($y*(int)$tsg);
      echo " $e hours will spent for watching a computer screen".'<br/>';
      ?>