Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Action Question 2

Status
Not open for further replies.

tekpr00

IS-IT--Management
Jan 22, 2008
186
CA
Here is my code
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] xml:lang="en" lang="en">
 <head>
  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  
  <title> Payform form </title>
 
 </head>
 <body>
 <div>
 <form action="handle_form.php"
 method="post">

 <p> Employee Name <input type="text"
 name="name" size="20" /></p>

<p> Employee ID <input type="text"
 name="empid" size="10" /></p>

<p> Hours <input type="text"
 name="hours" size="4" /></p>

 <p> Pay Rate <input type="text"
 name="payrate" size="6" /></p>

<input type="submit" name="submit"
value="Calculate" />
</form>
//Get the values from the $_POST array
$employeename =$_POST['name']
$employeeid =$_POST['empid']
$hours =$_POST['hours']
$payrate =$_POST['payrate']

//Calculate
$totalpay = $hours * $payrate
$payrolltaxrate = 0.12
$parolltax = $totalpay * $payrolltaxrate
$netpay = $totalpay - $deductable

//print result
<h>Pay Stub</h>
print "<div><p>Employee Name :<br />
<span class=\"number\">$name</span>

Emplyeee ID :<br /><span class=\"number\">$empid</span>

Hours:  <br /><span class=\"number\">$hours</span>

Pay Rate:  <br /><span class=\"number\">$payrate</span>

Total Pay:  <br /><span class=\"number\">$totalpay</span>

Payroll Tax:  <br /><span class=\"number\">$parolltax</span>

Net Pay:  <br /><span class=\"number\">$netpay</span></p></div>";


?>
</body>
</html>

Most of the erros that I am getting are
<h>Pay Stub</h>
You have used the element named above in your document, but the document type you are using does not define an element of that name. > is highlighted and underelined

Also
<span class=\"number\">$name</span>
You have used a character that is not considered a "name character" in an attribute value. The backslash in class=\ is highlighted and underlined.

</body>
You may have neglected to close an element, or perhaps you meant to "self-close" an element, that is, ending it with "/>" instead of ">".

I was hoping to get an out put like this:

Employee Name Employee ID Hours Pay Rate
(Calculate Button)

Pay Stub
Employee Name: Steve
Employee ED: 456
Hours Worked: 12.98
Pay Race: 4.98
Total Pay: 64.644
PayrollTax: 7.756848
Net Pay: 56.883552
 
These are all validation errors rater than actual PHP errors.

With that said, the first error:
<h>Pay Stub</h>
You have used the element named above in your document, but the document type you are using does not define an element of that name. > is highlighted and underelined

Is probably due to the fact that there is no <h> element. Heading elements are defined as h1 to h6. The larger the number the less important the heading is.

So what you probably want is an <h1></h1>

The other errors are likely due to trying to validate the source code with the un-executed PHP code. What you want to do is execute your page, and then validate just the resulting HTML that is delivered to the browser.




----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
How would I
1) execute my page and
2) validate the resulting HTML seperately

When I tried to access the file from browser without valiadtion, it gives me the follwoing errors in the browser:

Employee Name

Employee ID

Hours

Pay Rate
//Get the values from the $_POST array $employeename =$_POST['name'] $employeeid =$_POST['empid'] $hours =$_POST['hours'] $payrate =$_POST['payrate'] //Calculate $totalpay = $hours * $payrate $payrolltaxrate = 0.12 $parolltax = $totalpay * $payrolltaxrate $netpay = $totalpay - $deductable //print result
Pay Stub
print "

Employee Name :
$name Emplyeee ID :
$empid Hours:
$hours Pay Rate:
$payrate Total Pay:
$totalpay Payroll Tax:
$parolltax Net Pay:
$netpay
"; ?>
 
get your php working. render the page to html (by loading it in a browser), grab the rendered source code and feed that to the validator.


If you are getting php code in your html then most likely you are doing something wrong. A classic error is to have named the file something.html.
 
To execute a page you call the the page in the browser.

If your XAMP installation is on the same machine as your browser:

If you are double clicking the page, or opening it from the file open option in the browser then you are bypassing the XAMP server, and thus not executing the PHP.

Once the PHP is actually executed, doing a view source code from the browser should show nothing but the resulting HTML. No PHP should ever be visible in the browser if done correctly.



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top