Открытие окна на авторизацию?
Доброе все суток.
Добрые люди помогите пожалуйста. Как сделать чтоб ссылка открывалась в этом же окне или в новом окне браузера? выложу два кода html и php, где моя ошибка? index.html <!doctype html> <html> <head> <meta charset="utf-8"> </head> <body> <form action="ispmgr.php" method="get"> <table width="400px"> <tr> <td>Панель управления</td> </tr> <tr> <td ><input name="login" type="text" placeholder="Username" /></td> </tr> <tr> <td><input name="pass" type="password" placeholder="Password" /></td> </tr> <tr> <td><input class="button" type="submit" value="Вход"/></td> </tr> </table> </form> </body> </html> ispmgr.php <?php $login=@$_GET['login']; $pass=@$_GET['pass']; if (!empty($login)) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'https://webvm.ru:1500/ispmgr?out=xml&func=auth&username='.$login.'&password='.$pass); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); $res = curl_exec($curl); if(!$res) { echo '<script language="javascript"> window.location="https://webvm.ru:1500/ispmgr?&func=auth&username='.$login.'&password='.$pass.'";</script>'; } else { $doc = new SimpleXMLElement($res); foreach ($doc->auth as $id) { echo '<script language="javascript"> window.location="https://webvm.ru:1500/ispmgr?auth='.$id['id'].'";</script>'; } foreach ($doc->error as $type) { echo '<script language="javascript"> window.location="https://webvm.ru:1500/ispmgr?&func=auth&username='.$login.'&password='.$pass.'";</script>'; } } curl_close($curl); } ?> помогите разобраться что не так? почему не работает. |
olegalimov,
а через header('Location') ? |
Цитата:
|
в коде нет ошибок. проблема с отображением.
|
Цитата:
|
написал вот так, не работает
$res = curl_exec($curl); if(!$res) { header("Location: https://webvm.ru:1500/ispmgr?&func=auth&username='.$login.'&password='.$pass.'"); /* Перенаправление броузера */ //echo '<script language="javascript"> window.location="https://webvm.ru:1500/ispmgr?&func=auth&username='.$login.'&password='.$pass.'";</script>'; } else { $doc = new SimpleXMLElement($res); foreach ($doc->auth as $id) { header("Location: https://webvm.ru:1500/ispmgr?auth='.$id['id'].'"); /* Перенаправление броузера */ //echo '<script language="javascript"> window.location="https://webvm.ru:1500/ispmgr?auth='.$id['id'].'";</script>'; } foreach ($doc->error as $type) { header("Location: https://webvm.ru:1500/ispmgr?&func=auth&username='.$login.'&password='.$pass.'"); /* Перенаправление броузера */ //echo '<script language="javascript"> window.location="https://webvm.ru:1500/ispmgr?&func=auth&username='.$login.'&password='.$pass.'";</script>'; } } curl_close($curl); } ?> |
olegalimov,
Проблема с кавычками. Не так header("Location: https://webvm.ru:1500/ispmgr?&func=auth&username='.$login.'&password='.$pass.'");а так header("Location: https://webvm.ru:1500/ispmgr?&func=auth&username=".$login."&password=".$pass);и непонятно, почему после ispmgr? идет сразу знак амперсанда. Если ispmgr имя скрипта, то логичнее будет так header("Location: https://webvm.ru:1500/ispmgr?func=auth&username=".$login."&password=".$pass); Ну и остальные ссылки поправить. |
исправил, не работает! пишет, ошибка сервера 500!
<?php $login=@$_GET['login']; $pass=@$_GET['pass']; if (!empty($login)) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'https://my.webvm.ru/ispmgr?out=xml&func=auth&username='.$login.'&password='.$pass); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); $res = curl_exec($curl); if(!$res) { header("Location: https://my.webvm.ru/ispmgr?func=auth&username=".$login.'&password='.$pass); /* Перенаправление броузера */ } else { $doc = new SimpleXMLElement($res); foreach ($doc->auth as $id) { header("Location: https://my.webvm.ru/ispmgr?auth=".$id['id']); /* Перенаправление броузера */ } foreach ($doc->error as $type) { header("Location: https://my.webvm.ru/ispmgr?func=auth&username=".$login.'&password='.$pass); /* Перенаправление броузера */ } } curl_close($curl); } ?> |
olegalimov,
добавить расширение скрипта header("Location: [url]https://my.webvm.ru/ispmgr.php?[/url]...) добавить exit()после header. Ну или спрашивать на специализированных форумах php |
Часовой пояс GMT +3, время: 17:09. |