Transfer value to another page was successful, I have read many topics on this subject, stockoverflow really helped me with this.
On the first page (eg page1.php) I have input. Normally I type a value to it.
With php I write in a session variable and after clicking submit I can transfer this value to the other side (eg page2.php) which is a simple contact page. This value is pasted into a textarea field.
My problem is that it takes only the value that I type directly to the input, which is located in page1.php. I wanted to create rather calculator, which will consist of the price according to the entered number of kilograms of product. (the kilogram is the value entered in the input).
How do I get a form field was clean, and the Order the product was all redirected correctly?
My code in page1.php :
<?php session_start(); $_SESSION['towar1'] = $cena1; ?> <form method="get" action="kontakt.php"> <input id="wart1" type="number" value="0" name="towar1" class="ilosc" required> </form>
My code in page2.php(conttact page) :
<?php session_start(); $cena1 = $_GET['towar1']; ?> <label for="wiadomosc"></label> <textarea placeholder="" name="wiadomosc" required><?php echo $cena1 ?></textarea>
when I trying to figure how to get good value of product price (e.g. for 1 kg will be 19$) i wrote code of this kind directly on my page2.php:
<?php echo $cena1*19 ?>
But when I do this, any direct entrance on the contact page gives me already written text which is 0 (zero).
Can I avoid that 0? How can I make textarea will be blank always, and my page1.php (calculator) will calculate correct number (const which is 19$ per kilo and number of kilos that you entered in input)