PHP setting session variables on button click -
when user click either 4/6 'snacks per shipment', , weekly/fortnightly/monthly 'shipment frequency', function displays details on right hand side above button.
i'm noob developer looking store whatever information user chooses, session variable once button 'choose snacks' clicked. in example, looking store 4 , fortnightly.
here php code when starting session
<?php session_start(); include_once 'dbconnect.php'; if(isset($_post['choose'])) { $unit = document.getelementbyid('unit').innerhtml; $frequency = document.getelementbyid('frequency').innerhtml; // set session variables $_session["unit"] = $unit; $_session["frequency"] = $frequency; } ?> here code related button
<div class="pricing-button" method="post"> <a href="session.php" class="btn btn-yellow btn-rounded btn-lg" name="choose" type="submit">choose snacks</a> </div> here code related scraping user chooses
<script> function change(unit){ document.getelementbyid('unit').innerhtml = unit; } function frequency(frequency){ document.getelementbyid('frequency').innerhtml = frequency; } </script> and here's i'm testing if session variables working or not
<?php session_start(); ?> <!doctype html> <html> <body> <?php // echo session variables set on previous page echo "customer wants " . $_session["unit"] . "<br>"; echo "this many times " . $_session["frequency"] . "<br>"; ?>
on first code, have mix of php/js...
try put unit , frequency on same form, after submit.
and remember... turnon display_errors directive on php.ini

Comments
Post a Comment