I have one big problem. My website is made in PHP MVC pattern but I don't use "POST" submit in one page and now I have big problem because I need to pass quantity onto products/order page but if i use Submit button my next page will not work. So I must fix this problem with passing user input field into session variable and get it into another page without using submit button or input button post. I know i must use ajax but when i choose to use localhost/products/order as a page where variable need to pass it doesn't get the variable.
this is my app/views/inc/products/show.php view where i have form which need to make session variable when user change quantity.
I want to use a href button to get into next page but when user click a href it must save input field into session variable. I don't know how to do it. Please help me
<div class="form-group">
<label for="proquantity">Product Quantity: </label>
<input type="text" name="proquantity" id="proquantity" class="form-control form-control-lg" value="">
</div>
<a href="<?php echo URLROOT; ?>/products/order<?php $_SESSION['productId'] = $data['product']->id;?>" class="btn btn-dark">MORE</a>
So my problem is that I don't know how to get this value which is in input with id = "proquantity" and i want that value to pass into this view: app/views/inc/products/order.php
I am not familiar with javascript or jquery so I hope someone will help me to save value which is in input "proquantiy" and save the same value into $_session['proquantity'] so with that I can easily get the value into my order.php view. I can not use sumbit button because i will need to change a lot of staff if i do it now..
What i try? When i try to use this script like this: at the begin of my file of the show.php I add this javascript:
<script type="text/javascript">
$(function(){
$('#autosend').blur(function(){
$.post('<?php echo APPROOT;?>/views/inc/products/order.php',{fieldval:$(this).val()},function(response){
alert(response);
});
})
})
</script>
Then I add this input into same file:
After that I add into my view: app/views/inc/products/order.php
And then I add code to view order.php get that variable like this:
<?php
$_SESSION["proquantity"] = $_POST["fieldval"];
echo $_SESSION["proquantity"];?>
And then i get this error on my order.php page ****Notice: Undefined index: fieldval in C:\xampp\htdocs\shareposts\app\views\products\order.php on line 8 aa
I hope someone will point me to fix my problem and fix this error. I hope i will not need to use submit form.
htaccess of public
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
htaccess of app
Options -Indexes