fenerfan Posted August 14, 2007 Share Posted August 14, 2007 Hi Everyone, I have just started using Php and was fiddling around with it. Here is my problem, I am trying to create a form where the user enters the data and gets back a result, keeping all the original data on the screen when the result is produced (Sort of a sticky form), only problem is that it won't work....... for me at least... here is the code: <html> <head> <img src= "Rams_Header.jpg" </head> <Body> <?php $Mortgage = $_POST['mortgage']; $Interest = $_POST['interest']; $Years = $_POST['years']; ?> <?php if (isset($Mortgage) && isset($Interest) && isset($Years)) $Payments =$Mortgage*($Interest/12)/(1-(1/pow((1+$Interest/12),$Years*12))); ?> <form> <form action = "Ass2.php" method = "post"> <table> <tr> <td><b>Please Enter Mortgage Amount: </b></td> <td><input type = "text" name = "mortgage" value = <? echo $Mortgage ?>> </td> <td><TH rowspan="4"><img src="BOB07_GOLD_WINNER.gif"></td> </tr> <tr> <td><b>Please Enter Interest Rate: </b></td> <td><input type = "text" name = "interest" value = <? echo $Interest ?>> </td> </tr> <tr> <td><b>Please Enter Number of Years for Repayment: </b></td> <td><input type = "text" name = "years" value = <? echo $Years ?>> </td> </tr> </tr> <tr> <td></td> <td><input type="submit" name ="SUBMIT" value="submit me"></td> </tr> <tr> <td> <?php if (isset($Payments)) echo "Your Morgate Repayments will be $" .round($Payments,2) ?> </td> </tr> </table> </form> </Body> </html> Anybody have an Idea??? Thanks in Advance Quote Link to comment https://forums.phpfreaks.com/topic/64779-solved-please-help/ Share on other sites More sharing options...
uwannadonkey Posted August 14, 2007 Share Posted August 14, 2007 before i consider looking at your code: rule 1 in the forum guidelines: Various Things not to do: a) DON'T Describe your question or problem as urgent, super important, must have by tommorrow etc... The experts answering your questions are contributing their time and expertise for Free. If you have an urgent problem and need priority help, consider advertising in the Freelancing forum. and number 2, put your code in the brackets without the spaces please and that code is very sloppy.. Quote Link to comment https://forums.phpfreaks.com/topic/64779-solved-please-help/#findComment-323143 Share on other sites More sharing options...
hitman6003 Posted August 14, 2007 Share Posted August 14, 2007 Make sure that the action of your form tag is the name of your script...or leave it out...or set it equal to $_SERVER['PHP_SELF']. Also, I'm not sure, but I think you may need to remove the spaces between the attribute="value" in your html tags. <form action = "Ass2.php" method = "post"> maybe should be: <form action="Ass2.php" method="post"> Quote Link to comment https://forums.phpfreaks.com/topic/64779-solved-please-help/#findComment-323144 Share on other sites More sharing options...
hvle Posted August 14, 2007 Share Posted August 14, 2007 maybe this will make your code work better <input type = "text" name = "mortgage" value="<? echo $Mortgage ?>"> note the double quote around the passed in value. If you don't wrap it with quote and you have space or any kind funny character, it will be prob. If you play with PHP long enough, you will use some sort of template mechanism because this way is simple and very hard to manage if you have multiple form and more inputs Quote Link to comment https://forums.phpfreaks.com/topic/64779-solved-please-help/#findComment-323147 Share on other sites More sharing options...
fenerfan Posted August 14, 2007 Author Share Posted August 14, 2007 thanks, messed around and got it to work. Quote Link to comment https://forums.phpfreaks.com/topic/64779-solved-please-help/#findComment-323148 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.