Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 09-16-2007, 04:36 PM Conversion Question
MGT-Evelath's Avatar
Average Talker

Posts: 21
Trades: 0
Well, I attempted to handle this assignment on my own, but it's gotten to the point that I need assistance. I am making a Converter. From Fahrenheit to Celsius, and I can't seem to get my current code to work:

Code:
<html>
<head> 
<title>Temperature Conversion</title> 
</head> 
<body> 
<h2>Temperature Conversion</h2> 


<form method="post"
      action="<?php echo $_SERVER['PHP_SELF']; ?>">
Fahrenheit:
<input type = "text" name = "fTemp"> 
<br>
Celsius:
<input type = "text" name = "cTemp">

<br> 
<input type = "submit"> 
</form> 

<?



{
    
  if(isset($_POST['fTemp']))
  $cTemp = (float)(($fTemp - 32) / 1.8 );
}
    


{
  if(isset($_POST['cTemp']))
  $fTemp = (float)(1.8 * $cTemp) + 32;

}


?>

</body>
</html>
It doesn't come up with any errors, and i've tried about 100 forms of this code. I just can't get the information processed and output into the same box.
MGT-Evelath is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-16-2007, 05:00 PM Re: Conversion Question
Super Talker

Posts: 130
Trades: 0
in the input text box, you need to place:

PHP Code:
<input type='text' name='fTemp' value='<?=$_POST['fTemp']?>'>
__________________
flann

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
flann is offline
Reply With Quote
View Public Profile
 
Old 09-16-2007, 05:40 PM Re: Conversion Question
MGT-Evelath's Avatar
Average Talker

Posts: 21
Trades: 0
Code:
<html>
<head> 
<title>Temperature Conversion</title> 
</head> 
<body> 
<h2>Temperature Conversion</h2> 


<form method="post"
      action="<?php echo $_SERVER['PHP_SELF']; ?>">
Fahrenheit:
<input type = "text" name = "fTemp" value='<?=$_POST['fTemp']?>'> 
<br>
Celsius:
<input type = "text" name = "cTemp" value='<?=$_POST['cTemp']?>'>

<br> 
<input type = "submit"> 
</form> 

<?



{
    
  if(isset($_POST['fTemp']))
  $cTemp = (float)(($fTemp - 32) / 1.8 );
}
    


{
  if(isset($_POST['cTemp']))
  $fTemp = (float)(1.8 * $cTemp) + 32;

}


?>

</body>
</html>
However nothing occurs when I input the amount.
MGT-Evelath is offline
Reply With Quote
View Public Profile
 
Old 09-16-2007, 08:52 PM Re: Conversion Question
Experienced Talker

Posts: 44
Name: Kuldeep Sahi
Trades: 0
Try this:

PHP Code:
<?
{
  if(isset(
$_POST['fTemp']))
  
$cTemp = (float)(($fTemp 32) / 1.8 );
}
{
  if(isset(
$_POST['cTemp']))
  
$fTemp = (float)(1.8 $cTemp) + 32;
}
?>
<html>
<head> 
<title>Temperature Conversion</title> 
</head> 
<body> 
<h2>Temperature Conversion</h2> 

<form method="post"
      action="<?php echo $_SERVER['PHP_SELF']; ?>">
Fahrenheit:
<input type = "text" name = "fTemp" value='<?=$fTemp?>'> 
<br>
Celsius:
<input type = "text" name = "cTemp" value='<?=$cTemp?>'>

<br> 
<input type = "submit"> 
</form> 
</body>
</html>
__________________

Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE
Kuldeep2195 is offline
Reply With Quote
View Public Profile Visit Kuldeep2195's homepage!
 
Old 09-17-2007, 01:54 AM Re: Conversion Question
MGT-Evelath's Avatar
Average Talker

Posts: 21
Trades: 0
There is still no output. =/

Thanks for the assistance thus far.

Last edited by MGT-Evelath; 09-17-2007 at 01:58 AM..
MGT-Evelath is offline
Reply With Quote
View Public Profile
 
Old 09-17-2007, 02:35 AM Re: Conversion Question
Experienced Talker

Posts: 44
Name: Kuldeep Sahi
Trades: 0
Made some changes and also tested it.

PHP Code:
<?
if($_POST['fTemp'] >' ')
{
    
$fTemp $_POST['fTemp'];    
    
$cTemp = (float)(($fTemp 1.0 32) / 1.8 );
}
else
{
    
$cTemp $_POST['cTemp'];    
    
$fTemp = (float)(1.8 $cTemp) + 32;
}
?>
<html>
<head> 
<title>Temperature Conversion</title> 
</head> 
<body> 
<h2>Temperature Conversion</h2> 

<form method="post"
      action="<?php echo $_SERVER['PHP_SELF']; ?>">
Fahrenheit:
<input type = "text" name = "fTemp" value='<?=$fTemp?>'> 
<br>
Celsius:
<input type = "text" name = "cTemp" value='<?=$cTemp?>'>

<br> 
<input type = "submit"> 
</form> 
</body>
</html>
__________________

Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE
Kuldeep2195 is offline
Reply With Quote
View Public Profile Visit Kuldeep2195's homepage!
 
Reply     « Reply to Conversion Question
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.27318 seconds with 12 queries