php - form session data not posting, sessions working -
i've been tinkering few days. checked out posts related , still can't quite work. able take , steer me in right direction?
i have site gets loaded div on page. working great except form data. can load session data test , works fine, can't seem of entered form data.
i have session_start(); included @ top under opening php tag in connection.php. connection.php required on each page.
connection.php beginning.
<? session_start();
here code samples addvehicle.php (not posting it's huge , rest not relevant, can if need though)
...
<script type="text/javascript"> $(document).ready(function() { $('form#newvehicleform').submit(function() { <?php $trucknumbera=$_post["trucknumber"]; $_session['trucknumber']=$trucknumbera; $_session['info']="this info"; ?> $("#mainwindow").load("addvehiclepost.php"); return false; }); }); </script>
.....
<form id="newvehicleform" class="newvehicleform" method="post" action="<?php echo $php_self;?>"> <table> <tr> <td> truck number </td> <td> <input name="trucknumber" class="validate[required,custom[number]]" type="text" id="trucknumber" autofocus autocomplete="off" required /> </td> </tr> <tr> <td> <br> <input type="submit" id="submit" class="s-submit" alt="submit" value="submit"> </td> </tr> </table> </form>
the test of, addvehiclepost.php
require ('./connection.php'); echo "<br>info: " .$_session['info']. "<br>"; $trucknumber=$_session['trucknumber']; echo "<br>trucknumber: " .$trucknumber;
and here output addvehiclepost.php
info: info
trucknummer:
so can see it's passing $_session , function working can't pass submitted data.
anyone have ideas on getting go?
thanks in advance. -colin.
when execute first script php, there no form data.
and php fragment executed there not besides transfering empty post value (null) local variable , session array.
i think think php code gets executed when javascript called, not case! first php executed, , result echoed browser. page rendered , javascript executed.
so php part of code copy empty value (and sets static 1 well, that's see) @ time form page first loaded browser.
then javascript acts. mean in case there no form post request, request addvehiclepost.php
script. no post request means no $_post
data. isn't accessed in loaded script anyway.
i don't know if able fix this, hope enabled understand structural error of code. have seen newbie know.
Comments
Post a Comment