techker Posted October 26, 2014 Share Posted October 26, 2014 Hey guys i got an invoice form that has the totals in a span id SUB ::<span id="small_total"></span><br /> TPS :: <span id="tps"></span><br /> TVQ :: <span id="tvq"></span><br /> GRAND TOTAL :: <span id="grand_total"></span><br /> so its part of a form,when i submit to add to databse i can't seem to figure out how to get the values of the id? i have tried a few things with no success.. exp in the add.php page(form submit action) $GT = "<script language='javascript'>document.getElementById(grand_total);</script>"; Quote Link to comment https://forums.phpfreaks.com/topic/292073-getting-span-id-in-php/ Share on other sites More sharing options...
mac_gyver Posted October 26, 2014 Share Posted October 26, 2014 i got an invoice form that has the totals in a span id things you display on a web page are just for display purposes. if you need the total on the server, you should calculate it from the original source data values so that someone cannot alter the DOM in the browser and submit any value they want to your server-side code. Quote Link to comment https://forums.phpfreaks.com/topic/292073-getting-span-id-in-php/#findComment-1494809 Share on other sites More sharing options...
MDCode Posted October 26, 2014 Share Posted October 26, 2014 If you are submitting the form without JavaScript, the way you are doing it is not possible. Why not just wrap it in a <form>? Quote Link to comment https://forums.phpfreaks.com/topic/292073-getting-span-id-in-php/#findComment-1494822 Share on other sites More sharing options...
techker Posted October 26, 2014 Author Share Posted October 26, 2014 im going to post my code.it's in a for.. <form id="submit_form" action="ADD.php" method="post" > SUB ::<span id="small_total"></span><br /> TPS :: <span id="tps"></span><br /> TVQ :: <span id="tvq"></span><br /> GRAND TOTAL :: <span id="grand_total"></span><br /> <div class="action_bar"> <input type="submit" name="submit" /> </div> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="42%">PRODUCT</td> <td width="11%">QTY</td> <td width="10%">PRICE</td> <td width="37%">TOTAL</td> </tr> <tr> <td><p class="large"><input type="text" id="street" class="item_title" name="obj1"> </p></td> <td> <p class="small"> <input type="text" id="number" value="0" class="item_quantity" name="qty1"></p> </td> <td><p class="small"> <input type="text" value="0"class="item_price" name="price1"></p> </td> <td><span class="item_small_total"></span></td> </tr> <tr> <td><p class="large"><input type="text" id="street" class="item_title" name="obj2"> </p></td> <td> <p class="small"> <input type="text" id="number" value="0" class="item_quantity" name="qty2"></p> </td> <td><p class="small"> <input type="text" value="0"class="item_price" name="price2"></p></td> <td><span class="item_small_total"></span></td> </tr> <tr> <td><p class="large"><input type="text" id="street" class="item_title" name="obj3"> </p></td> <td> <p class="small"> <input type="text" id="number" value="0" class="item_quantity" name="qty3"> </p></td> <td><p class="small"> <input type="text" value="0"class="item_price" name="price3"></p> </td> <td><span class="item_small_total"></span></td> </tr> <tr> <td><p class="large"> <input type="text" id="street" class="item_title" name="obj4"> </p></td> <td> <p class="small"> <input type="text" id="number" value="0" class="item_quantity" name="qty4"> </p></td> <td><p class="small"> <input type="text" value="0"class="item_price" name="price4"></p> </td> <td><span class="item_small_total"></span></td> </tr> <tr> <td><p class="large"><input type="text" id="street" class="item_title" name="obj5"> </p></td> <td> <p class="small"> <input type="text" id="number" value="0" class="item_quantity" name="qty5"></p> </td> <td><p class="small"> <input type="text" value="0"class="item_price" name="price5"></p> </td> <td><span class="item_small_total"></span></td> </tr> <tr> <td><p class="large"><input type="text" id="street" class="item_title" name="obj6"> </p></td> <td> <p class="small"> <input type="text" id="number" value="0" class="item_quantity" name="qty6"></p> </td> <td><p class="small"> <input type="text" value="0"class="item_price" name="price6"></p> </td> <td><span class="item_small_total"></span></td> </tr> <tr> <td><p class="large"><input type="text" id="street" class="item_title" name="obj7"> </p></td> <td> <p class="small"> <input type="text" id="number" value="0" class="item_quantity" name="qty7"></p> </td> <td><p class="small"> <input type="text" value="0"class="item_price" name="price7"></p> </td> <td><span class="item_small_total"></span></td> </tr> </table> </form> Quote Link to comment https://forums.phpfreaks.com/topic/292073-getting-span-id-in-php/#findComment-1494835 Share on other sites More sharing options...
MDCode Posted October 26, 2014 Share Posted October 26, 2014 If you want it accessible through a form and still seen in your span, you'll have to add it to a hidden input. <input type="hidden" name="grand_total" value="grand_total_amount_here"> Either way it will still be editable by a user. The only way to do it securely would be to follow mac_gyver's advice. Quote Link to comment https://forums.phpfreaks.com/topic/292073-getting-span-id-in-php/#findComment-1494856 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.