Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 表单提交是否停止使用scrollify.move的其他功能?_Php_Jquery_Html_Jquery Scrollify - Fatal编程技术网

Php 表单提交是否停止使用scrollify.move的其他功能?

Php 表单提交是否停止使用scrollify.move的其他功能?,php,jquery,html,jquery-scrollify,Php,Jquery,Html,Jquery Scrollify,我有一个使用scrollify.js的单页网站 我有两个按钮可以将窗口滚动到相关部分,用于填写表单并返回页面顶部 第一个按钮是(icon2),带有一个(a)标记,带有一个scrollToB类 第二个按钮(home btn)带有另一个(a)标记和一类淡入淡出的scrollTo,因此您可以单击此按钮返回顶部 在我点击表单上的提交之前,滚动和淡入淡出两个功能都在工作,尽管淡入淡出功能仍在按钮上工作,但两个按钮(Scrollyfy.move)上的单独点击功能已停止工作?无论表单是否未通过验证或是否已发送

我有一个使用scrollify.js的单页网站

我有两个按钮可以将窗口滚动到相关部分,用于填写表单并返回页面顶部

第一个按钮是(icon2),带有一个(a)标记,带有一个scrollToB类

第二个按钮(home btn)带有另一个(a)标记和一类淡入淡出的scrollTo,因此您可以单击此按钮返回顶部

在我点击表单上的提交之前,滚动和淡入淡出两个功能都在工作,尽管淡入淡出功能仍在按钮上工作,但两个按钮(Scrollyfy.move)上的单独点击功能已停止工作?无论表单是否未通过验证或是否已发送,此行为都是相同的

一个有效的例子是www.devonfoodmovement.com

我已经搜索了几个小时,找不到任何相关的

所有脚本/样式都是从my functions.php文件加载的

索引(FrontPage.php)

form.php

    <?php include ('form_process.php');?>
    <div class="grey">
        <div class="container-contact">
            <form id="contact" method="post" >
                <div id="column-contact-left">
                <div class='contact-logo'></div>
                <h3>Contact the Devon Food Movement</h3>
                <fieldset id="field-no-ui">
                    <input placeholder="Your name" type="text" tabindex="1" name="name1" value="<?= $name ?>" >
                </fieldset>
                <span class="error"><?= $name_error ?></span>
                <fieldset id="field-no-ui">
                    <input placeholder="Your Email Address" type="text" name="email" value="<?= $email ?>" tabindex="2" >
                </fieldset>
                <span class="error"><?= $email_error ?></span>
                </div>
                <div id="column-contact-right">
                <fieldset id="field-no-ui">
                    <textarea id="field-no-ui" placeholder="Type your Message Here...." name="message" value="<?= $message ?>" tabindex="3" ></textarea>
                </fieldset>
                <div class="g-recaptcha" data-sitekey="sitekey" ></div>
                <span class="captcha-failed"><?= $captchafailed; ?></span>
                <span class="sent"><?= $sent; ?></span>
                <fieldset id="field-no-ui">
                    <button name="submit" type="submit" id="contact-submit" data-submit="...Sending">Submit</button>
                </fieldset>
                </div>
            </form>
            <script src="https://www.google.com/recaptcha/api.js" async defer></script>
        </div>
    </div>

联系德文郡食品运动

我在这里看到了很多问题,这是如何组合起来的。 首先,您可以防止移动链接的默认行为

$(".scrollTo").click(function(event) {
  event.preventDefault();
  $.scrollify.move(0);
});
    <?php
    function register_my_menus() {
        register_nav_menus(
                array( 'header_menu' => __( 'Header Menu', 'DevonFoodMovement'),
                       'footer_menu' => __( 'Footer Menu', 'DevonFoodMovement')
                     )
                );
    }
    add_action('init', 'register_my_menus');

    /* GOOGLE FONTS */

    function DFM_styles()
    {
        wp_register_style('DFM', get_template_directory_uri() . '/style.css', array(), '1.0', 'all');
        wp_enqueue_style('DFM');


    }
    add_action('wp_enqueue_scripts', 'DFM_styles');

    function DFM_form()
    {
        wp_register_style('DFMform-css', get_template_directory_uri() . '/form.css', array(), '1.0', 'all');
        wp_enqueue_style('DFMform-css');
    }
    add_action('wp_enqueue_scripts', 'DFM_form');

    function DFM_scripts()
    {
        wp_register_script('j-query-min', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js' );
        wp_enqueue_script('j-query-min');

        wp_register_script('j-query-mob-min', 'http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js' );
        wp_enqueue_script('j-query-mob-min');

        wp_register_script( 'modernizr', get_template_directory_uri() . '/modernizr-1.6.min.js' );
        wp_enqueue_script( 'modernizr' );

        wp_register_script('scrollify-min', 'https://cdn.jsdelivr.net/npm/jquery-scrollify@1.0.17/jquery.scrollify.min.js' );
        wp_enqueue_script('scrollify-min');

        wp_register_script('jquery-custom', get_template_directory_uri() . '/customjs.js' );
        wp_enqueue_script('jquery-custom');
    }
    add_action('wp_enqueue_scripts', 'DFM_scripts');

    function load_fonts() 
    {
        wp_register_style('et-googleFonts', 'https://fonts.googleapis.com/css?family=Josefin+Sans:300,400');
        wp_enqueue_style( 'et-googleFonts');
    }
    add_action('wp_print_styles', 'load_fonts');

        /* 
         * To change this license header, choose License Headers in Project Properties.
         * To change this template file, choose Tools | Templates
         * and open the template in the editor.
         */
    $(document).ready(function(){
        $('article').css({'height':($(window).height())+'px'}).css({'width':($(window).width())+'px'});
        $(window).resize(function(){
        $('article').css({'height':($(window).height())+'px'}).css({'width':($(window).width())+'px'});
        });
    });
    $(document).scroll(function(){
        $(function() {
            $.scrollify({
            section: ".section-class",
            sectionName : "section-name",
            /*interstitialSection : ".footer-end",*/
            scrollSpeed: 1000,
            setHeights: true
            });
        });
    });
    $(document).scroll(function (){
        if(window.location.href === "http://devonfoodmovement.com/#devonfoodmovement"){
        $('.home-btn').fadeOut(500);

        } else if(window.location.href === "http://devonfoodmovement.com/#contact-us") {
        $('.home-btn').fadeIn(500).css('display','block');
        }    
    });
    $(document).ready(function (){
        $(".scrollTo").click(function() {
            $.scrollify.move(0);
        });
    });
    $(document).ready(function (){
        $(".scrollToB").click(function() {    
            $.scrollify.move(1);    
        });
    });
    <?php include ('form_process.php');?>
    <div class="grey">
        <div class="container-contact">
            <form id="contact" method="post" >
                <div id="column-contact-left">
                <div class='contact-logo'></div>
                <h3>Contact the Devon Food Movement</h3>
                <fieldset id="field-no-ui">
                    <input placeholder="Your name" type="text" tabindex="1" name="name1" value="<?= $name ?>" >
                </fieldset>
                <span class="error"><?= $name_error ?></span>
                <fieldset id="field-no-ui">
                    <input placeholder="Your Email Address" type="text" name="email" value="<?= $email ?>" tabindex="2" >
                </fieldset>
                <span class="error"><?= $email_error ?></span>
                </div>
                <div id="column-contact-right">
                <fieldset id="field-no-ui">
                    <textarea id="field-no-ui" placeholder="Type your Message Here...." name="message" value="<?= $message ?>" tabindex="3" ></textarea>
                </fieldset>
                <div class="g-recaptcha" data-sitekey="sitekey" ></div>
                <span class="captcha-failed"><?= $captchafailed; ?></span>
                <span class="sent"><?= $sent; ?></span>
                <fieldset id="field-no-ui">
                    <button name="submit" type="submit" id="contact-submit" data-submit="...Sending">Submit</button>
                </fieldset>
                </div>
            </form>
            <script src="https://www.google.com/recaptcha/api.js" async defer></script>
        </div>
    </div>
    <?php
    function post_captcha($user_response) {
        $fields_string = '';
        $fields = array(
            'secret' => 'secret',
            'response' => $user_response
        );
        foreach($fields as $key=>$value)
            $fields_string .= $key . '=' . $value . '&';
        $fields_string = rtrim($fields_string, '&');
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, 'https://www.google.com/recaptcha/api/siteverify');
        curl_setopt($ch, CURLOPT_POST, count($fields));
        curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, True);
        $result = curl_exec($ch);
        curl_close($ch);
        return json_decode($result, true);
    }
    $res = post_captcha($_POST['g-recaptcha-response']);
    $name_error = $email_error = $captchafailed = "";
    $name = $email = $message = $sent = "";
    if (isset($_POST['submit']) AND (!$res['success'])) {    
            $captchafailed = "please check reCaptcha";
    }
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        if (empty($_POST["name1"])) {
            $name_error = "Name is required";
        } else {
            $name = test_input($_POST["name1"]);
            if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
                $name_error = "Only letters and white space allowed";
            }
        }
        if (empty($_POST["email"])) {
            $email_error = "Email is required";
        } else {
            $email = test_input($_POST["email"]);
            if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
                $email_error = "Invalid email format";
            }
        }
        if (empty($_POST["message"])) {
            $message = "";
        } else {
            $message = test_input($_POST["message"]);
        }
        if ($name_error == '' and $email_error == '' and ($res['success']) ){
            $message_body = '';
            unset($_POST['submit']);
            foreach ($_POST as $key => $value){
                $message_body .=  "$key: $value\n";
            }
            $email = $_POST['email'];
            $to = '@gmail.com';
            $subject = 'Contact Form Submit';
            $headers = 'From:' . $email . "\n" . 'Reply-to: ' . $email . "\n"  ;
            if (mail($to, $subject, $message, $headers)) {
                $sent = "Message sent";
                $name = $email = $message = '';
            }
        }    
    }
    function test_input($data) {
        $data = trim($data);
        $data = stripslashes($data);
        $data = htmlspecialchars($data);
        return $data;
    }
$(".scrollTo").click(function(event) {
  event.preventDefault();
  $.scrollify.move(0);
});