SHARE
TWEET

Untitled

a guest Sep 22nd, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. I don't understand how this is an unexpected if????
  2.  
  3. Parse error: syntax error, unexpected 'if' (T_IF), expecting '{' in C:\xampp\htdocs\websites\calculateInterest.php on line 5
  4.  
  5. html:
  6.  
  7. <html>
  8.     <body>
  9.         <form action="calculateInterest.php" method="post">
  10.             Calculation for: <input type="text" name="username"> (name)<br>
  11.             Principal: $ <input type="number" name="principal"><br>
  12.             Annual interest Rate: <input type="number" name="interest">%<br>
  13.             Term <input type="number" name="term"> years<br>
  14.             <br>
  15.             <input type="submit" value="Calculate" />
  16.             <br>
  17.             The total payable will be: $
  18.         </form>
  19.     </body>
  20. </html>
  21.  
  22. php:
  23. <html>
  24. <body>
  25. <?php function calc ()
  26.  
  27.     if (!empty($_POST['username']))
  28. {
  29.     // We have form data! Let’s process it!
  30.    
  31.     // calculation here
  32.     $total = ($_POST['principal']) * (1 + (($_POST['interest'])/100)* ($_POST['term']));
  33. //$a = $principal * ( 1 + ($rate/100) * $term ) );
  34.     echo 'The total payable will be: $ '$total;
  35. }
  36.  
  37.     ?>
  38.     </body>
  39.     </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top