cyfer65 Posted December 9, 2011 Share Posted December 9, 2011 Is there anyway to pass a variable/data on a form post without having it displayed in html source..?Like insert the value of an input right as the post occurs...So if $DATA = ABC123and you have a form input like:<input type="submit" id="1" name="AAA" value="XXX"/>Would there be anyway to tack on the $DATA = ABC123 to the end of the input value "XXX" when the form is submitted like "XXX-ABC123" ..? Link to comment Share on other sites More sharing options...
niche Posted December 9, 2011 Share Posted December 9, 2011 q1 - $_POST array. q2 - style="visibility:hidden;" Link to comment Share on other sites More sharing options...
cyfer65 Posted December 9, 2011 Author Share Posted December 9, 2011 q1 - $_POST array. q2 - style="visibility:hidden;" mind explaining that to me..? Link to comment Share on other sites More sharing options...
niche Posted December 9, 2011 Share Posted December 9, 2011 http://www.w3schools.com/php/php_post.asp http://www.w3schools.com/cssref/pr_class_visibility.asp They're are pretty basic concepts, that I'm happy to help you with if needed. Link to comment Share on other sites More sharing options...
cyfer65 Posted December 9, 2011 Author Share Posted December 9, 2011 http://www.w3schools...hp/php_post.asp http://www.w3schools..._visibility.asp They're are pretty basic concepts, that I'm happy to help you with if needed. Are you just saying to use hidden inputs like:<input type="hidden" name="AAA" value="XXX"/>and using $_POST["AAA"] to get the "XXX" value..?? Link to comment Share on other sites More sharing options...
niche Posted December 9, 2011 Share Posted December 9, 2011 Yes. Link to comment Share on other sites More sharing options...
cyfer65 Posted December 9, 2011 Author Share Posted December 9, 2011 is that the only way to do a hidden data pass on form submit..?because i already new this method, thus why i asked if there was anyway to pass a variable/data on a form post without having it displayed in html source code.. Link to comment Share on other sites More sharing options...
niche Posted December 9, 2011 Share Posted December 9, 2011 mysql_query won't show in your page view. That means store your data in a mysql table. That's the limit of my current knowledge. Link to comment Share on other sites More sharing options...
cyfer65 Posted December 9, 2011 Author Share Posted December 9, 2011 would there be anyway for when the form is submitted to intercept/check the submitted value against an already set variable, then replace the existing input value with that variable like: $VALUE[XXX] = "ABC123";and you have a form input like:<input type="submit" value="XXX"/>so when its submitted the "XXX" value gets replaced with "ABC123" Link to comment Share on other sites More sharing options...
niche Posted December 9, 2011 Share Posted December 9, 2011 Sure. An if statement in the file you pass the action to on submitting your form. Link to comment Share on other sites More sharing options...
cyfer65 Posted December 9, 2011 Author Share Posted December 9, 2011 so it cant be intercepted/changed before its submitted to the new page then..? Link to comment Share on other sites More sharing options...
niche Posted December 9, 2011 Share Posted December 9, 2011 Sure. Put some code together and I'll help you with it tomorrow. It's after midnight and time to suspend operations. Link to comment Share on other sites More sharing options...
cyfer65 Posted December 9, 2011 Author Share Posted December 9, 2011 not sure what code to put together though..?what code or function could be used to intercept a post before its transmitted to the next page..? Link to comment Share on other sites More sharing options...
niche Posted December 9, 2011 Share Posted December 9, 2011 POST data is not sent to the next page in a way that it can be viewed in the page source because it's sent as the $_POST array that I access with php (I'm sure there are probably other ways to do that). That's the way I manipulate the $_POST array. If you can, send at least the start of the script that's the target of the action attribute of your form. What kind of form will it be? html or something else? Link to comment Share on other sites More sharing options...
cyfer65 Posted December 9, 2011 Author Share Posted December 9, 2011 im not sure if your understanding what im wanting to do..? I have a form like this $AAA = "111"$BBB = "222"<form method="post"><input type="submit" name="AAA" value="AAA"/><br><input type="submit" name="BBB" value="BBB"/></form>What I'm wanting to do is, when one of the input buttons are pressed/submitted its value is replaced by a variable that is already set that corresponds the existing input value or name.So during the form submission before the page refreshes passing on the $_POST array, the input value of "AAA" needs to be switched out to "111" in the $_POST array..Is that possible at all..? Link to comment Share on other sites More sharing options...
niche Posted December 9, 2011 Share Posted December 9, 2011 With just php you'd send the output from your form to the action target (a php file) and the php file would do its thing and refresh your entire page with the transformed data. javascript with php would do a similar thing except javascript would only refresh part of your page http://www.w3schools..._livesearch.asp Link to comment Share on other sites More sharing options...
cyfer65 Posted December 9, 2011 Author Share Posted December 9, 2011 everything is occurring on one index.php file..when first visited the index.php echos out the html code and form.when the form is submitted the target is itself index.php - so the page just refreshes passing the $_POST array back to itself where there is php code to interpret the $_POST array and perform other functions accordingly.. But i need to switch out the input value of "AAA" to "111" in the $_POST array before it is read on the submit/refresh Link to comment Share on other sites More sharing options...
justsomeguy Posted December 9, 2011 Share Posted December 9, 2011 You can use Javascript to change the values of any form elements. You can have a function called by the onsubmit handler for the form to change the values right before the form gets submitted. Link to comment Share on other sites More sharing options...
niche Posted December 9, 2011 Share Posted December 9, 2011 I suppose you could do it that way with a if statement that checks for whether a key is defined in your $_POST array. So, put that if statement in your php. If it's not there already how would you start it? Link to comment Share on other sites More sharing options...
thescientist Posted December 9, 2011 Share Posted December 9, 2011 Is there a reason it has to be changed before being submitted, as opposed to niche idea of just validating the value on the server side, so it's it AAA, then just treat as if it was 111. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.