dantebeck Posted October 16, 2013 Share Posted October 16, 2013 Hi, I have the following code, which does implement "autologin" on the Pandora FMS monitoring solution <?php $pwd = "pandora"; $user = "admin"; $data = $user.$pwd; $data = md5($data); echo "DEBUG md5sum $data user $user Pass $pwd<br>"; echo '<form name=test method=post action="http://10.1.10.10/pandora_console/index.php?loginhash=auto&sec=estado&sec2=operation/agentes/estado_agente&refr=60">'; echo '<input type="hidden" name="loginhash_data" value="'.$data.'">'; echo '<input type="hidden" name="loginhash_user" value="'.$user.'">'; echo '<input type="submit">'; echo '</form>'; Thats a sample code that comes with the Pandora FMS install, however, it displays a "Submit" button you have to hit in order to get to the URL, how can I get rid off that submit button and have it redirect me automatically? Thanks Quote Link to comment Share on other sites More sharing options...
vinny42 Posted October 16, 2013 Share Posted October 16, 2013 You could try javascript: http://stackoverflow.com/questions/3102889/javascript-autosubmit-form and yes, just typed "javascript form autosubmit" into google :-) Quote Link to comment Share on other sites More sharing options...
dantebeck Posted October 16, 2013 Author Share Posted October 16, 2013 I tried different examples -- could you please give me an example with my code? Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted October 16, 2013 Share Posted October 16, 2013 Not sure of the "best" approach, but here is one that I use: $url = 'http://10.1.10.10/pandora_console/index.php?loginhash=auto&sec=estado&sec2=operation/agentes/estado_agente&refr=60'; $data = array('loginhash_data'=>$data, 'loginhash_user'=>$user); http_post_redirect($url, $data); function http_post_redirect($url='', $data=array(), $doc=true) { $data = json_encode($data); if($doc) { echo "<html><head></head><body>"; } echo " <script type='text/javascript'> var data = eval('(' + '$data' + ')'); var jsForm = document.createElement('form'); jsForm.method = 'post'; jsForm.action = '$url'; for (var name in data) { var jsInput = document.createElement('input'); jsInput.setAttribute('type', 'hidden'); jsInput.setAttribute('name', name); jsInput.setAttribute('value', data[name]); jsForm.appendChild(jsInput); } document.body.appendChild(jsForm); jsForm.submit(); </script>"; if($doc) { echo "</body></html>"; } exit; } Quote Link to comment 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.