Passing variables from forms with Javascript & PHP?

Eric

New member
I'm trying to send several variables from a form to server, but I want to send all of them as one variable, so I did 2 forms, one to enter data, and another one with one hidden text input and button with function collecting data from all text inputs in first form and inserting it into the hidden one and then submit the combined variable.
does this way make any sens? or do you know any ways to shorten url address sending same number of variables (needed to query database) best if without modifying htaccess files and storing all overwrites database.
My code looks something like so:

javascript:
(...)
cvalue1 = trim( document.getElementById( 'field1' ).value );
(...)
cvalue10 = trim( document.getElementById( 'field10' ).value );

allinone = cvalue1 + '--' + cvalue1 + (...) + cvalue10;
document.getElementById( 'hiddenfield' ).value = allinone;

php:
if( isset( $_GET['hiddenfield'] ) )
{
$allvalues = $_GET['hiddenfield'];
(...)
$exploder = explode("--", $allvalues);
$value1 = $exploder[0];
(...)
$value10 = $exploder[9];
}

any cons using this weird method?
thanks.
Thank you DzSoundNirvana.
That was exactly what I needed, I just started to learn javascript and somehow did not get that far, and because of that it looks like I'm just making my life much harder. I think I should first study all the functions available so I know what I'm doing. Well finally I know the right way of passing url's. Thx.
 
<script type="javascript">
function mash(){
var something = document.getElementById("name").value;
var something2 = document.getElementById("name2").value;
window.location = "http://yoursite.com?info=" + somethihng + "--" + something2;
}
</script>

//php

$info = explode("--",$_GET['info']);
print_r($info);
 
Back
Top