patator Posted August 30, 2005 Share Posted August 30, 2005 Hello In this page, I calculate a specific dimension based on physical specifications of golfers. Once the calculation is made, I would like the user to be able to save the information in his account. I know how to create the fields in the customer table, show them in the account_edit.php page etc.... I know how to check if the user isn't logged: // if the customer is not logged on, redirect them to the login page if (!tep_session_is_registered('customer_id')) { $navigation->set_snapshot(); tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); } But then, I don't know how to proceed. Once the user is logged I don't know how to save the calculated information and redirect him back to http://www.clubfitting.net/tech_meas_length.php. I would greatly appreciate if somebody could give me some tips because I don't really guess in which direction should I go.... Thanks Patrice Link to comment Share on other sites More sharing options...
patator Posted August 30, 2005 Author Share Posted August 30, 2005 Sorry to knock again Could anybody be of any help ? Where should I start from ? Thanks Patrice Hello In this page, I calculate a specific dimension based on physical specifications of golfers. Once the calculation is made, I would like the user to be able to save the information in his account. I know how to create the fields in the customer table, show them in the account_edit.php page etc.... I know how to check if the user isn't logged: // if the customer is not logged on, redirect them to the login page if (!tep_session_is_registered('customer_id')) { $navigation->set_snapshot(); tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); } But then, I don't know how to proceed. Once the user is logged I don't know how to save the calculated information and redirect him back to http://www.clubfitting.net/tech_meas_length.php. I would greatly appreciate if somebody could give me some tips because I don't really guess in which direction should I go.... Thanks Patrice <{POST_SNAPBACK}> Link to comment Share on other sites More sharing options...
Guest Posted August 30, 2005 Share Posted August 30, 2005 Hi Patrice, I think you could pass the calculated info as a value to the next page for storage. So I would expect your jscript say calculate 3*4=12 you pass that as a parameter say shaft=12 to the next page which is the one generated when someone presses the "calculate" button To store it you could create a new table or add a new field for the customer in the dbase whatever is more convenient for you. Also to get back to the page drop an anchor like in the code you posted: $navigation->set_snapshot(); Link to comment Share on other sites More sharing options...
patator Posted August 31, 2005 Author Share Posted August 31, 2005 Thanks again Enigma. What I was looking for was indeed this anchor. Thanks Patrice Hi Patrice, I think you could pass the calculated info as a value to the next page for storage. So I would expect your jscript say calculate 3*4=12 you pass that as a parameter say shaft=12 to the next page which is the one generated when someone presses the "calculate" button To store it you could create a new table or add a new field for the customer in the dbase whatever is more convenient for you. Also to get back to the page drop an anchor like in the code you posted: $navigation->set_snapshot(); <{POST_SNAPBACK}> Link to comment Share on other sites More sharing options...
Guest Posted August 31, 2005 Share Posted August 31, 2005 maybe I did it wrong this time :lol: I think the selections from both options should be passed through page transitions since tep_draw_xxx functions have the get/post argument and then retrieve it from the HTTP_POST_VARS or HTTP_GET_VARS arrays. So you make the calculation in the new page with the parameters passed not the old as I said earlier. You could do the calc in jscript but its more work I think. Link to comment Share on other sites More sharing options...
patator Posted September 1, 2005 Author Share Posted September 1, 2005 I noticed it as well... I'm working through a transition page and retrieve the info through HTTP_POST_VARS I will post my method once I finished with it. Thanks Patrice maybe I did it wrong this time :lol: I think the selections from both options should be passed through page transitions since tep_draw_xxx functions have the get/post argument and then retrieve it from the HTTP_POST_VARS or HTTP_GET_VARS arrays. So you make the calculation in the new page with the parameters passed not the old as I said earlier. You could do the calc in jscript but its more work I think. <{POST_SNAPBACK}> Link to comment Share on other sites More sharing options...
patator Posted September 1, 2005 Author Share Posted September 1, 2005 Hello I found half of the solution. If the user is already logged, I can save the information into his customer account, how: in www.clubfitting.net/tech_meas_length.php, I save the result of the fitting in a variable called $length_saved and I post it as follow: <input type="hidden" name="length_saved" value="<? echo $length_saved ;?>"> <input type="hidden" name="origin" value="<? echo $length_saved ;?>"> <input type="submit" value="<? echo save_value; ?>" name="submit"></td> When the form is post, it opens the file tech_meas_save <form NAME="result_fitting" ACTION="<? echo tep_href_link(FILENAME_SAVE, '', 'NONSSL'); ?>" METHOD="post";"> Here is the content of tech_meas_save if (!tep_session_is_registered('customer_id')) { $navigation->set_snapshot(); tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); } else { //on r?cup?re les variables post?es $length_saved = $_POST['length_saved']; $iron_saved = $_POST['iron_saved']; $wood_saved = $_POST['wood_saved']; $grip_saved = $_POST['grip_saved']; if ($length_saved) { tep_db_query("update " . TABLE_CUSTOMERS . " set customer_shaft_length = '" . $length_saved ."' where customers_id = '" . (int)$customer_id . "'"); } if ($iron_saved) { tep_db_query("update " . TABLE_CUSTOMERS . " set customer_iron_flex = '" . $iron_saved ."' where customers_id = '" . (int)$customer_id . "'"); } if ($wood_saved) { tep_db_query("update " . TABLE_CUSTOMERS . " set customer_wood_flex = '" . $wood_saved ."' where customers_id = '" . (int)$customer_id . "'"); } if ($grip_saved) { tep_db_query("update " . TABLE_CUSTOMERS . " set customer_grip_size = '" . $grip_saved ."' where customers_id = '" . (int)$customer_id . "'"); } $origin_href = tep_href_link($navigation->snapshot['page'], tep_array_to_string($navigation->snapshot['get'], array(tep_session_name())), $navigation->snapshot['mode']); $navigation->clear_snapshot(); tep_redirect($origin_href); } If the user is not logged, then he's redirected to the login page. Once he's logged, he is redirected to tech_meas_save (thanks to $navigation->set_snapshot();). When he gets back to that page, the previously post variables are lost and the original page is out of memory (tech_meas_length.php). How could I do to keep the post variables in memory when coming back to tech_meas.php from the login.php page and then go back to the very first page of calculation (tech_meas_length.php). As I'm definitly stuck I hope somebody will be able to help me (a lot ;) ) Thanks for reading this post Patrice Link to comment Share on other sites More sharing options...
patator Posted September 5, 2005 Author Share Posted September 5, 2005 Sorr for knocking again, but could somebody give me a tip.... Thanks Patrice Hello I found half of the solution. If the user is already logged, I can save the information into his customer account, how: in www.clubfitting.net/tech_meas_length.php, I save the result of the fitting in a variable called $length_saved and I post it as follow: <input type="hidden" name="length_saved" value="<? echo $length_saved;?>"> <input type="hidden" name="origin" value="<? echo $length_saved;?>"> <input type="submit" value="<? echo save_value; ?>" name="submit"></td> When the form is post, it opens the file tech_meas_save <form NAME="result_fitting" ACTION="<? echo tep_href_link(FILENAME_SAVE, '', 'NONSSL'); ?>" METHOD="post";"> Here is the content of tech_meas_save if (!tep_session_is_registered('customer_id')) { $navigation->set_snapshot(); tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); } else { //on r?cup?re les variables post?es $length_saved = $_POST['length_saved']; $iron_saved = $_POST['iron_saved']; $wood_saved = $_POST['wood_saved']; $grip_saved = $_POST['grip_saved']; if ($length_saved) { tep_db_query("update " . TABLE_CUSTOMERS . " set customer_shaft_length = '" . $length_saved ."' where customers_id = '" . (int)$customer_id . "'"); } if ($iron_saved) { tep_db_query("update " . TABLE_CUSTOMERS . " set customer_iron_flex = '" . $iron_saved ."' where customers_id = '" . (int)$customer_id . "'"); } if ($wood_saved) { tep_db_query("update " . TABLE_CUSTOMERS . " set customer_wood_flex = '" . $wood_saved ."' where customers_id = '" . (int)$customer_id . "'"); } if ($grip_saved) { tep_db_query("update " . TABLE_CUSTOMERS . " set customer_grip_size = '" . $grip_saved ."' where customers_id = '" . (int)$customer_id . "'"); } $origin_href = tep_href_link($navigation->snapshot['page'], tep_array_to_string($navigation->snapshot['get'], array(tep_session_name())), $navigation->snapshot['mode']); $navigation->clear_snapshot(); tep_redirect($origin_href); } If the user is not logged, then he's redirected to the login page. Once he's logged, he is redirected to tech_meas_save (thanks to $navigation->set_snapshot();). When he gets back to that page, the previously post variables are lost and the original page is out of memory (tech_meas_length.php). How could I do to keep the post variables in memory when coming back to tech_meas.php from the login.php page and then go back to the very first page of calculation (tech_meas_length.php). As I'm definitly stuck I hope somebody will be able to help me (a lot ;) ) Thanks for reading this post Patrice <{POST_SNAPBACK}> Link to comment Share on other sites More sharing options...
patator Posted September 5, 2005 Author Share Posted September 5, 2005 I found the answer thanks to a post from Chemo related to global variable. Here is what I did: in the calculation page <? if (tep_session_is_registered('length_saved')) { ?> <tr> <td colspan="3" class="fitting_result"><? echo length_saved_account . $length_saved;?></td> </tr> <? tep_session_unregister('length_saved'); tep_session_unregister('origin_href2'); } ?> in the page saving the information, I now have : <?php require('includes/application_top.php'); require('includes/classes/http_client.php'); //on stocke la page de d?part if (!tep_session_is_registered('origin_href2')){ $origin_href2 = tep_href_link($navigation->snapshot['page'], tep_array_to_string($navigation->snapshot['get'], array(tep_session_name())), $navigation->snapshot['mode']); tep_session_register('origin_href2'); } //on r?cup?re les variables post?es if (!tep_session_is_registered('length_saved')){ $length_saved = $_POST['length_saved']; tep_session_register('length_saved'); } if (!tep_session_is_registered('iron_saved')){ $iron_saved = $_POST['iron_saved']; tep_session_register('iron_saved'); } if (!tep_session_is_registered('wood_saved')){ $wood_saved = $_POST['wood_saved']; tep_session_register('wood_saved'); } if (!tep_session_is_registered('grip_saved')){ $grip_saved = $_POST['grip_saved']; tep_session_register('grip_saved'); } // if the customer is not logged on, redirect them to the login page if (!tep_session_is_registered('customer_id')) { $navigation->clear_snapshot(); $navigation->set_snapshot(); tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); } else { if ($length_saved) { tep_db_query("update " . TABLE_CUSTOMERS . " set customer_shaft_length = '" . $length_saved ."' where customers_id = '" . (int)$customer_id . "'"); } if ($iron_saved) { tep_db_query("update " . TABLE_CUSTOMERS . " set customer_iron_flex = '" . $iron_saved ."' where customers_id = '" . (int)$customer_id . "'"); } if ($wood_saved) { tep_db_query("update " . TABLE_CUSTOMERS . " set customer_wood_flex = '" . $wood_saved ."' where customers_id = '" . (int)$customer_id . "'"); } if ($grip_saved) { tep_db_query("update " . TABLE_CUSTOMERS . " set customer_grip_size = '" . $grip_saved ."' where customers_id = '" . (int)$customer_id . "'"); } //$origin_href = tep_href_link($navigation->snapshot['page'], tep_array_to_string($navigation->snapshot['get'], array(tep_session_name())), $navigation->snapshot['mode']); // $navigation->clear_snapshot(); tep_redirect($origin_href2); } Hope it will help some people Thanks to Enigma for his help patrice :thumbsup: Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.