Jump to content


Photo

Help on forms


  • Please log in to reply
3 replies to this topic

#1 radhekrishna

radhekrishna
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 31 March 2006 - 11:26 PM

Hello PHP people,
I am new to PHP.So I started reading a PHP books.While reading a got a small doubt please help me .


My doubt
==========

I want to display currency in INDIA Rupess when US Dollar given as input.
Input is US Dollar.Output is Indian Rupee.
it is simply currency convertion.
1 US$=46 Indian Rupee.

So My aim is when Us dollar is input ina text form.When submit button press it must display the indian rupee in same page.

so I written like this and found many errors .please help me and rectify.
<html>
<form>
Enter US Dollar
<input type=text name=USD>
<input type=submit value="submit">
<?php
$rate=46;
$INR=$USD*$rate;
?>
The coverted dollar is:
<?php
echo$(INR)
?>
</form>
<html>

I got some errors.please help me.




#2 play_

play_
  • Staff Alumni
  • Advanced Member
  • 717 posts

Posted 31 March 2006 - 11:32 PM

post errors.

and try

echo $INR;
instead of
echo$(INR)

regex.kat.sh --- regex library
u.kat.sh ---- url shortener
tabbit.org ---- tabbed pastebin

#3 earl_dc10

earl_dc10
  • Members
  • PipPipPip
  • Advanced Member
  • 71 posts

Posted 31 March 2006 - 11:35 PM

try this as a backup plan if nothing else works

<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST"> //reloads page when submitted
<input type="text" name="USD">
<input type="submit" name="sub" value="submit">
</form>

<?php
$sub = $_POST['sub']; // makes a variable from the Posted Data
$USD = $_POST['USD'];
$rate = 46;

if(isset($sub)) // when submit is pressed, this runs
{
   $INR = $rate*$USD
   echo "The converted dollar is ".$INR;

   // if you really wanted to be fancy you could do this:
   echo $USD." in Rupee is ".$INR;
}

got a problem? Google helps many of those in need

#4 radhekrishna

radhekrishna
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 03 April 2006 - 05:18 PM

[!--quoteo(post=360510:date=Apr 1 2006, 05:05 AM:name=earl_dc10)--][div class=\'quotetop\']QUOTE(earl_dc10 @ Apr 1 2006, 05:05 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
try this as a backup plan if nothing else works

<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST"> //reloads page when submitted
<input type="text" name="USD">
<input type="submit" name="sub" value="submit">
</form>

<?php
$sub = $_POST['sub']; // makes a variable from the Posted Data
$USD = $_POST['USD'];
$rate = 46;

if(isset($sub)) // when submit is pressed, this runs
{
   $INR = $rate*$USD
   echo "The converted dollar is ".$INR;

   // if you really wanted to be fancy you could do this:
   echo $USD." in Rupee is ".$INR;
}
[/quote]

The output is not coming

Errors Are:

//reloads page when submitted
Notice: Undefined index: sub in D:\prog\i-d.php on line 7

Notice: Undefined index: USD in D:\prog\i-d.php on line 8

please tell me how to do this program if anyone know




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users