Menu
I’m suppose to have a code that has a HTML front end with a text box that will allow me to enter in a amount in Cents. Then have a php backend that will conver the cents into dollars. I have my conversion of cents / 100 i’m not sure how to read the infor from my html to the PHP script portion
Could someone please help explain what I need to do hear?? I’m a little lost at this point
Thanks,
any information would be much appreciated
[code=php]<?
$dollars = $_POST['input'] / 100;
echo $dollars
?>[/code]
[code=html]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html>
<html>
<head>
<title> Welcome to conversion of cents to dollars</title>
</head>
<body>
<center>
<form action="calculate.php" method="post">
Enter a number then click the button: <input type="text" name="input" size="10">
<input type="submit" value="Convert">
</form>
</center>
</body>
</html>[/code]
[code=php]<?
$dollars = $_POST['input'] / 100;
echo $dollars
?> [/code]
<input type="submit" value="Convert">
<input type="submit" value="Convert">
[code=html],[CODE], or [code=php])
[code=html]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org//TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title> Welcome to conversion of cents to dollars</title>
</head>
<body>
<form action="m5donovanCP4-5.php" method="post">
<center>
Enter a number then click the button: <input type="text" name="input" size="10">
<input type="submit" value="Convert">
</center>
</form>
</body>
</html>
[/code]
[code=php]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org//TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<title>Project 4-5 - Cents to Dollar Conversion</title>
</head>
<body>
<center>Your output is:
<?php
$dollars = $_POST['input'] / 100;
print $dollars;
?>
</center>
</body>
</html>
[/code]
[code=html]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org//TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title> Welcome to conversion of cents to dollars</title>
</head>
<body>
<center>
<form action="m5donovanCP4-5.php" method="post"> <center> Enter a number then click the button:
<input type="text" name="input" size="10"> <input type="submit" value="Convert">
</form>
</center>
</body>
</html>[/code]
[code=php]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org//TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<title>Project 4-5 - Cents to Dollar Conversion</title>
</head>
<body>
<center>Your output is:
<?php
$dollars = $_POST['input'] / 100;
print $dollars;
?>
</center>
</body>
</html>[/code]
[code=php]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org//TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title> Welcome to conversion of cents to dollars</title>
</head>
<body>
<form action="m5donovanCP4-5.php" method="post">
<center>
Enter a number then click the button: <input type="text" name="input" size="10">
<input type="submit" value="Convert">
</center>
</form>
</body>
</html>
_____________________________________________________________
PHP Code -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org//TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<title>Project 4-5 - Cents to Dollar Conversion</title>
</head>
<body>
<?php
$dollars = sprintf('%01.2f', ((int)$_POST['input'] / 100));
print $dollars;
?>
</body>
</html>[/code]
[code=php]
$cents = 1234567890;
echo '$'.number_format($cents / 100, 2);
[/code]
0.1.9 — BETA 5.6