A
A
Andrey Smirnov2016-01-12 11:08:32
CMS
Andrey Smirnov, 2016-01-12 11:08:32

How to make a similar callback on HTML+JS?

Hello everyone, I have a question: there is a callback script written in HTML + JS + PHP:

<div class="call">
            <div class="call_form_bg" id="call_form">
                <div class="call_form">
          <a href="/" class="close_button">+</a>
                    <div class="form_text">Оставьте своё имя и номер телефона и наш менеджер с вами свяжется</div>
                    <form id="" method="post" name="calling_form" action="#callform">
                        <input class="form" type="text" name="name" placeholder="Имя" required="required">
                        <input class="form" type="text" name="phone" placeholder="Номер телефона:" id="phone" required="required">
                        <input class="form_submit" type="submit" name="submit" value="Заказать звонок">
                    </form>
                   <?php
if((isset($_POST['submit']))&&(isset($_POST['name'])&&$_POST['name']!="")&&(isset($_POST['phone'])&&$_POST['phone']!="")){ //Проверка отправилось ли наше поля name и не пустые ли они
                      echo "<div class='call_form'><a href="/" class='close_button'>+</a><h2>Мы вам позвоним в течении 10 минут</h2></div>";
}
                    ?>
                </div>
            </div>
        </div>
        <?
if((isset($_POST['submit']))&&(isset($_POST['name'])&&$_POST['name']!="")&&(isset($_POST['phone'])&&$_POST['phone']!="")){ //Проверка отправилось ли наше поля name и не пустые ли они
        $to = '[email protected]'; //Почта получателя, через запятую можно указать сколько угодно адресов
        $subject = 'Обратный звонок'; //Загаловок сообщения
        $message = '
                <html>
                    <head>
                        <title>'.$subject.'</title>
                    </head>
                    <body>
                        <p>Имя: '.$_POST['name'].'</p>
                        <p>Телефон: '.$_POST['phone'].'</p>                        
                    </body>
                </html>'; //Текст нащего сообщения можно использовать HTML теги
        $headers  = "Content-type: text/html; charset=utf-8 \r\n"; //Кодировка письма
        $headers .= "From: От меня\r\n"; //Наименование и почта отправителя
        mail($to, $subject, $message, $headers); //Отправка письма с помощью функции mail
}
?>
    <div id="callform" class="callform_dialog">
    <div>
        <a href="/" title="Закрыть" class="close_button">+</a>
    <img style="float: left;width: 40px;margin-left: 64px;margin-top: 10px;position: absolute;" src="[tag:mediapath]img/call_center.png" alt="м.">
        <h2 style="text-align: center;">
       Спасибо!</h2>
        <p style="text-align: center;    font-size: 0.9em;">Мы перезвоним Вам в течении 10 минут!</p>
    </div>
</div>

This code works and functions as it should. Question: is it possible to write everything the same, but using HTML AND JS (PHP is not needed) or at least approximately. I was puzzled by this question, because the CMS editor on which my site is located does not understand PHP, but understands HTML and JS. I tried to find this file on the ftp server, to change it no longer in the admin panel, but I did not find it.
Therefore, two questions arose:
1. Is it possible to somehow include a php code handler in the editor in CMS Made Simple (so that the php code itself does not appear as text)?
2. If the first question is impossible, is it possible to remake this code for HTML and JS, that is, remove php? But the functionality should be the same.
3. If you can answer the first question, please tell me how or what to read, and then I will understand myself.
Upd .: there was an idea to find the file where the page is generated, so that after generating, let's say the headers, insert this code after it. Is it possible? If yes, then plz tell me who has already encountered such a problem, where CMS Made Simple files are generated.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Io, 2016-01-12
@vawsan

  1. Is not a fact.
  2. Конечно, только весь html переместить в клиентскую часть, а на серввере оставить только rest api для ответов на пост запросы, которые делать через ajax POST и возвращать не все представление как тут, а только данные для его формирования.
    Хотя можно и представление вернуть, ajax это поддерживает, но это уже не считается шибко хорошим тоном.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question