Is it possible to save php values from a form for further use? -


i have form on 1 page calculates value depending on user has entered:

// process users calculations     $elecaq = trim($_post['elecaq']);     $elecday = trim($_post['elecday']);     $elecmonth = trim($_post['elecmonth']);     $elecyear = trim($_post['elecyear']);     $elecstanding_charge = trim($_post['elecstanding_charge']);  <input type="text" style="padding-left: 2px" class="text-box-find" name="elecaq" placeholder="0000" value="<?php if(isset($_post['elecaq'])) echo $_post['elecaq'];?>">    <input type="text" class="day" name="elecday" style="float: left; margin-right: 2px" value="<?php if(isset($_post['elecday'])) echo $_post['elecday'];?>" placeholder="day" />  <input type="text" class="month"  name="elecmonth" placeholder="month" style="float: left" value="<?php if(isset($_post['elecmonth'])) echo $_post['elecmonth'];?>">      <input type="text" class="year" name="elecyear" placeholder="year" style="float: left" value="<?php if(isset($_post['elecyear'])) echo $_post['elecyear'];?>">    <input type="text" style="padding-left: 2px" class="text-box-find" name="elecstanding_charge" placeholder=".00" value="<?php if(isset($_post['elecstanding_charge'])) echo $_post['elecstanding_charge'];?> "> 

when form gets submitted, page refreshes , user shown success message (the amount of money save) , form prompting them enter details request quote underneath.

my question is: going possible me save values somehow entered first form , send them in email when second form submitted?

the page gets refreshed when first form processed, when email sent second form values first form have included recieving email blank.

i hope have managed explain ok, hoping can tell me best way of doing this?


here section of code send email once second form submitted:

$emailto = 'email@email.co.uk';     $subject = 'savings calculator -submitted request '.$name;     $sendcopy = trim($_post['sendcopy']);     $body = "first name: $contactname \n\nbusiness name: $businessname \n\nemail: $email \n\nphone: $phone \n\nmobile: $mobile \n\nbest time of day call: $time\n\nusers calculations: $_session['elecaq']";      $headers = 'from: ' .' <'.$emailto.'>' . "\r\n" . 'reply-to: ' . $email; 

you need add session_start(); @ top of both pages.

assigning values session variable

$_session['elecaq'] = trim($_post['elecaq']); 

access session value

echo $_session["elecaq"]; 

try example

<?php session_start();  $_session['elecaq'] = trim($_post['elecaq']); $_session['$elecday'] = trim($_post['elecday']); $_session['$elecmonth'] = trim($_post['elecmonth']); $_session['$elecyear'] = trim($_post['elecyear']); $_session['$elecstanding_charge'] = trim($_post['elecstanding_charge']);  // access session values call echo $_session['elecaq']; ?> 

email code

just changed users calculations: $_session['elecaq']"; users calculations: ".$_session['elecaq'];

updated

$emailto = 'email@email.co.uk'; $subject = 'savings calculator -submitted request '.$name; $sendcopy = trim($_post['sendcopy']); $body = "first name: $contactname \n\nbusiness name: $businessname \n\nemail: $email \n\nphone: $phone \n\nmobile: $mobile \n\nbest time of day call: $time\n\nusers calculations: ".$_session['elecaq'];  $headers = 'from: ' .' <'.$emailto.'>' . "\r\n" . 'reply-to: ' . $email; 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -