Jump to content

Recommended Posts

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/64779-solved-please-help/
Share on other sites

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..

Link to comment
https://forums.phpfreaks.com/topic/64779-solved-please-help/#findComment-323143
Share on other sites

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">

Link to comment
https://forums.phpfreaks.com/topic/64779-solved-please-help/#findComment-323144
Share on other sites

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

 

Link to comment
https://forums.phpfreaks.com/topic/64779-solved-please-help/#findComment-323147
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.