getting this form to work

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Neller
Forum Newbie
Posts: 18
Joined: Sun Mar 27, 2005 4:56 am

getting this form to work

Post by Neller »

ok here is my codes

Code: Select all

<html> 
<head> 
<title>"You Better Pay Up" Loan Services</title> 
</head> 
<body> 

<center>
<h3>Welcome to "You Better Pay Up" Loan Services</h3>

You pay us ten percent every week, or else.

<form action="loanshark.php" method=post> 


My hovercraft costs $<input type="text" name="cost"> 
<p><input type="submit" name="submit" value="What's My Interest Payment?">

</form>

</center>

</body>
</html>

and here is my form page
<html> 
<head> 
<title>Loans</title> 
</head> 

<body> 

<?php 

$interest_rate = .14; 

function YouOweMe($cost, $interest_rate) { 

$weekly_payment = ($cost*$interest_rate); 

print "You better pay me \$$weekly_payment every week, or else!"; 

} 

YouOweMe($cost, $interest_rate); 

?> 


</body> 
</html>
but i get the following error when i try and view it in my local host

Notice: Undefined variable: cost in c:\program files\installedprograms\easyphp1-8\www\loanshark.php on line 20
You better pay me $0 every week, or else!

anybody no what im doing wrong anyhelp would be excellent thanks


feyd | Please review how to post code using

Code: Select all

and

Code: Select all

tags. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Try changing YouOweMe($cost, $interest_rate); to YouOweMe($_POST['cost'], $interest_rate);
Post Reply