Answer the question
In order to leave comments, you need to log in
How to pass data from a website form to another page?
Good day everyone!
I don’t understand how it works and what I can do, help me in any way (:
There is such a form on the “product” page.
The product has a number of its own variables that must be transferred to the “basket” page after clicking on the booking button.
<form method="POST" action="<?php echo $link_address;?>">
<input type="hidden" name="quantity" id="qntyt" value="1" min="1" />
<input type="hidden" name="hoursform" id="hoursf" value="<?php echo round( $pricing->hours ); ?>" min="1" />
<input type="hidden" name="priceform" id="pricef" value="<?php echo $pricing->base; ?>" />
<input type="hidden" name="addonform" id="addonf" value="<?php echo $addon->price; ?>" min="0" />
<input type="submit" value="Забронировать" />
</form>
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
var foo = getParameterByName('hoursform');
var bar = getParameterByName('addonform');
var baz = getParameterByName('priceform');
var pricevalue = parseFloat(baz);
Answer the question
In order to leave comments, you need to log in
Hello.
Everything is simple.
You paste it into your HTML:
(if you need to send it to another page, as you want, then use the action="/page.php" attribute and catch this request on another page)
<form method="POST" action="">
<label>Введите текст</label>
<input type="text" name="text" value="Просто текст">
<button type="submit" class="btn btn-success">Отправить текст</button>
</form>
<?php
if(!empty($_POST['text'])){
//тут уже у тебя будет то, что ты хотел, например, как мы указали, текст в форме, он выведется тут
//можешь проверишь просто: var_dump($_POST['text']);
//Дальше уже делай что тебе нужно, сохраняй в базу данных или куда ты хочешь, не забудь про
//фильтрации
$text = $_POST['text']; // не забудь про проверки и фильтрации.
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question