0

I'm working on a PHP project, and while there has been some progress I'm still struggling on a major part and I was advised to ask help on here. Basically, in the code shown below there's supposed to be 2 values given: one from the dropdown menu and one from the input box. I'm asking for help on how to make this work because I've tried searching the internet for answers but I feel like I'm mixing different things up. Does anyone know how to make the two multiply together with this information below? I'm new to PHP, so help is appreciated :-)

DISCLAIMER: I'm Dutch, my native language isn't English and I had to translate the code. Sorry if there's any mistakes.

page1.php (where the information gets filled in)

<html>
<head>
<title>Currency Calculator</title>
<style>
input[type=number] {
  -moz-appearance: textfield;
}

body {
    background-color: lightblue;
}

p {
  font-family:Arial;
}

a.button {
    -webkit-appearance: button;
    -moz-appearance: button;
    appearance: button;
    padding: 10px 24px;
    text-decoration: Arial;
    color: black;
    background-color: lightgreen;
}

a.button:hover {
    box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.19);
}

</style>
</head>
<body>

<h1> Convert currency to EUR </h1>

<form action="page2.php" method="get">
<p> Amount in euro: </p> 
<input type="number" name="amount" min="0" step=".01">
<br> <br>
<p> To which currency should it be converted? </p>
<select name="currency" id="currency">
<option value="0" selected>Select a currency</option>
  <option value="1.1011">US Dollar</option>
  <option value="1,5160">Canadian Dollar</option>
  <option value="0.8980">British Pound</option>
  <option value="10.5623">Swedish Crown</option>
  <option value="7.4551">Danish Crown</option>
  <option value="75.2170">Argentinian Peso</option>
  <option value="1.0670">Swiss Frank</option>
  <option value="1.6640">Australian Dollar</option>
  <option value="7.8811">Chinese Yuan</option>
  <option value="7.4892">Turkish Lira</option>
</select> 
<br> <br> <br>
<a href="page2.php" class="button">Convert!</a>
</form>

<?php
session_start();

$_GET['amount'] = $am;

$_SESSION['x'] = $am;

$_GET['currency'] = $cur;

$_SESSION['y'] = $cur;

?>  

</body>
</html> 

page2.php (where the calculations show)

<html>
<head>
<style>
body {
    background-color: lightblue;
}

p {
  font-family:Arial;
}
</style>
</head>
 <body>

 <?php
 session_start();

 $_SESSION['x'] * $_SESSION['y'] = $money;

 echo . $_SESSION['x'] . "<p> of your selected currency is equal to </p>" . $money . "<p>. </p><br>";
 echo "<p>1 EUR is equal to </p>" . $_SESSION['y'] . "<p> of your selected currency.</p>";

 ?>


 </body>
</html>

Thank you in advance!

Temani Afif
  • 245,468
  • 26
  • 309
  • 415
  • `session_start()` *must* go before *any* output. In other words, put it at the top of your pages. – John Conde Jun 04 '20 at 12:37
  • @John Conde I did that and it still does not work. I dont mean to bother you but i also did not find the answer in the similar question as it uses very different php statements. Could you please clarify what's wrong with the code if you have the time? –  Jun 08 '20 at 13:51

0 Answers0