Skip to content

Instantly share code, notes, and snippets.

@haruta
Created April 18, 2013 09:33
Show Gist options
  • Save haruta/5411458 to your computer and use it in GitHub Desktop.
Save haruta/5411458 to your computer and use it in GitHub Desktop.
add_hidden.php
<html>
<head>
<script language="javascript" type="text/javascript">
window.onload = function() {
var forms = document.getElementsByTagName('form');
for (var i = 0; i < forms.length; i++) {
var new_hidden = document.createElement('input');
new_hidden.type= 'hidden';
new_hidden.name = "input_key";
new_hidden.value = document.getElementById('input_key_source').value;
forms[i].appendChild(new_hidden);
}
}
</script>
</head>
<body>
<input type="hidden" id="input_key_source" name="key" value="<?php echo date('YmdHis'); ?>">
<form action="add_hidden.php" name="form1" method="post">
<input type="submit" name="submit1">
</form>
<form action="add_hidden.php" name="form2" method="get">
<input type="submit" name="submit2">
</form>
<pre>
post =
<?php
var_dump($_POST);
?>
</pre>
<pre>
get =
<?php
var_dump($_GET);
?>
</pre>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment