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 Link to comment https://forums.phpfreaks.com/topic/283016-quick-help/ 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 :-) Link to comment https://forums.phpfreaks.com/topic/283016-quick-help/#findComment-1454126 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? Link to comment https://forums.phpfreaks.com/topic/283016-quick-help/#findComment-1454133 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; } Link to comment https://forums.phpfreaks.com/topic/283016-quick-help/#findComment-1454134 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.