laravel中的表单未提交

时间:2018-07-22 22:07:14

标签: php laravel forms laravel-blade

基本上,我在视图中定义了一个表单:

@extends('layouts.front')

@section('content')

<div class="container">
<div class="row">

        <form action="{{ route('login') }}" method="POST">
        {{ csrf_field() }}
        <div class="form-group">
            <label>Korisnicko ime:</label>
            <input type="text" name="tbKorisnickoIme" class="form-control" />
        </div>

        <div class="form-group">
            <label>Lozinka:</label>
            <input type="password" name="tbLozinka" class="form-control"/>
        </div>

        <input type="submit" name="btnLogin" value="Login" class="btn btn-primary"/>

    </form>

    </div>
</div>

@endsection('content')

这是表单进入的布局

<!doctype html>

<head>
    <title>e-aukcije - </title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <!-- LINKS -->
    @section('appendCss')
    <link rel="apple-touch-icon" href="apple-touch-icon.png">
    <link rel="stylesheet" href="{{ asset('/') }}pics/product1/css/bootstrap.min.css">
    <link rel="stylesheet" href="{{ asset('/') }}pics/product1/css/normalize.css">
    <link rel="stylesheet" href="{{ asset('/') }}pics/product1/css/font-awesome.min.css">
    <link rel="stylesheet" href="{{ asset('/') }}pics/product1/css/jquery.countdown.css">
    <link rel="stylesheet" href="{{ asset('/') }}pics/product1/css/customScrollbar.css">
    <link rel="stylesheet" href="{{ asset('/') }}pics/product1/css/jquery-ui.css">
    <link rel="stylesheet" href="{{ asset('/') }}pics/product1/css/owl.theme.css">
    <link rel="stylesheet" href="{{ asset('/') }}pics/product1/css/prettyPhoto.css">
    <link rel="stylesheet" href="{{ asset('/') }}pics/product1/css/owl.carousel.css">
    <link rel="stylesheet" href="{{ asset('/') }}pics/product1/css/prettyPhoto.css">
    <link rel="stylesheet" href="{{ asset('/') }}pics/product1/css/jquery.fullPage.css">
    <link rel="stylesheet" href="{{ asset('/') }}pics/product1/css/transitions.css">
    <link rel="stylesheet" href="{{ asset('/') }}pics/product1/css/main.css">
    <link rel="stylesheet" href="{{ asset('/') }}pics/product1/css/color.css">
    <link rel="stylesheet" href="{{ asset('/') }}pics/product1/css/responsive.css">
    <script src="{{ asset('/') }}pics/product1/js/vendor/modernizr-2.8.3-respond-1.4.2.min.js"></script>
    @show
    <!-- ENDLINKS -->

</head>
<body class="tg-login">

    <div id="tg-wrapper" class="tg-wrapper tg-haslayout">

    <!-- NAVIGATION -->
    @include('components.nav')
    <!--ENDNAVIGATION -->

        <main id="tg-main" class="tg-main tg-haslayout">

            <main id="tg-main" class="tg-main tg-haslayout">        
            <div class="tg-homeslider tg-homerslidertwo">
                <img src="{{ asset('/') }}pics/product1/test_files/img-04.jpg" alt="image description" style="
                height: 200px;
                width: 100%;
                padding-bottom:  20px;">
            </div>
                <main id="tg-main" class="tg-main tg-mainvtwo tg-haslayout">

                    <!-- MAINCONTAINER -->
                    @yield('content')
                    <!-- ENDMAINCONTAINER -->

                </main>

            </main>
        </main>
    </div>

    <!-- FOOTER -->
    @include('components.footer')
    <!--ENDFOOTER -->



</body>

这是web.php中的路由

Route::post('/login', 'FrontendController@login')->name('login');

这是前端控制器

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class FrontendController extends Controller
{
private $data = [];

public function login(Request $request){
    $user = $request->get('tbKorisnickoIme');
    $pass = $request->get('tbLozinka');
    $this->data['user'] = $user;
    $this->data['pass'] = $pass;
    return view('pages.login', $this->data);
}

public function register(){
    return view('pages.register');
}

}

提交表单后,它应该去查看“登录”,就像在表单操作中看到的一样,这里是:

@extends('layouts.front')

@section('content')

<p>{{ $user }}</p>

@endsection

但是,什么都没有发生,当我尝试提交表单时,没有打开任何页面,实际上什么也没发生。

有什么想法吗?

更新:这是引起问题的js

jQuery(document).ready(function(){
"use strict";

/*------------------------------------------
        HEADER FIVE NAVIGATION
------------------------------------------*/
var _btnnav = jQuery('#tg-btnnav');
var _wrapper = $('#tg-wrapper');
_btnnav.on('click', function () {
    _wrapper.toggleClass('tg-sidenavshow');
});
/*------------------------------------------
        TOGGLE NAV BUTTON
------------------------------------------*/
var toggles = document.querySelectorAll(".tg-btnnav");
    for (var i = toggles.length - 1; i >= 0; i--) {
    var toggle = toggles[i];
    toggleHandler(toggle);
};
function toggleHandler(toggle) {
    toggle.addEventListener( "click", function(e) {
    e.preventDefault();
    (this.classList.contains("is-active") === true) ? this.classList.remove("is-active") : this.classList.add("is-active");
    });
}


/* -------------------------------------
        TAB ON HOVER
-------------------------------------- */
var _multiSelector = jQuery('.tg-femalecategorynav li a, .tg-malecategorynav li a, .tg-kidscategorynav li a');
_multiSelector.on('mouseenter',function() {
    $(this).tab('show');
});
/* -------------------------------------
        HOME SLIDER VERSION THREE
-------------------------------------- */

var $container = $('.tg-featuredproducts');
var $optionSets = $('.option-set');
var $optionLinks = $optionSets.find('a');
function doIsotopeFilter() {
    if ($().isotope) {
        var isotopeFilter = '';
        $optionLinks.each(function () {
            var selector = $(this).attr('data-filter');
            var link = window.location.href;
            var firstIndex = link.indexOf('filter=');
            if (firstIndex > 0) {
                var id = link.substring(firstIndex + 7, link.length);
                if ('.' + id == selector) {
                    isotopeFilter = '.' + id;
                }
            }
        });
        //$(window).load(function () {
            $container.isotope({
                //itemSelector: '.tg-productitem',
                filter: isotopeFilter
            });
        //});
        $optionLinks.each(function () {
            var $this = $(this);
            var selector = $this.attr('data-filter');
            if (selector == isotopeFilter) {
                if (!$this.hasClass('tg-active')) {
                    var $optionSet = $this.parents('.option-set');
                    $optionSet.find('.tg-active').removeClass('tg-active');
                    $this.addClass('tg-active');
                }
            }
        });
        $optionLinks.on('click', function () {
            var $this = $(this);
            var selector = $this.attr('data-filter');
            $container.isotope({itemSelector: '.tg-project', filter: selector});
            if (!$this.hasClass('tg-active')) {
                var $optionSet = $this.parents('.option-set');
                $optionSet.find('.tg-active').removeClass('tg-active');
                $this.addClass('tg-active');
            }
            return false;
        });
    }
}
var isotopeTimer = window.setTimeout(function () {
    window.clearTimeout(isotopeTimer);
    doIsotopeFilter();
}, 1000);
/* -------------------------------------
        COLLAPSE NAVIGATION
-------------------------------------- */
function collapseNav(){
    var _hasdropdown = jQuery('.tg-navigation ul li.tg-hasdropdown');
    _hasdropdown.prepend('<span class="tg-dropdowarrow"><i class="fa fa-angle-down"></i></span>');
    var _eventselector = jQuery('.tg-navigation ul li.tg-hasdropdown span');
    _eventselector.on('click', function(){
        jQuery(this).next().next().slideToggle(300);
    });
}
collapseNav();
/* -------------------------------------
        LOCATION MAP
-------------------------------------- */

/* -------------------------------------
        THEME ACCORDION
-------------------------------------- */
$(function() {
    $('.tg-panelcontent').hide();
    $('#tg-accordion h4:first').addClass('active').next().slideDown('slow');
    $('#tg-accordion h4').on('click',function() {
        if($(this).next().is(':hidden')) {
            $('#tg-accordion h4').removeClass('active').next().slideUp('slow');
            $(this).toggleClass('active').next().slideDown('slow');
        }
    });
});



/*------------------------------------------
        PRODUCT INCREASE
------------------------------------------*/
var _minusone = jQuery('em.minus');
var _plusone = jQuery('em.plus');
var _quantity = jQuery('#quantity1');
_minusone.on('click', function () {
    _quantity.val(parseInt(_quantity.val(), 10) - 1);
});
_plusone.on('click', function () {
    _quantity.val(parseInt(_quantity.val(), 10) + 1);
});
/* ---------------------------------------
        DIRECTION AWARE HOVER
--------------------------------------- */
jQuery('.tg-portfolio').each(function () {
    jQuery(this).hoverdir();
});
/* ---------------------------------------
        FULL PAGE SEARCH
--------------------------------------- */
var _btnsearch = jQuery('a[href="#tg-search"]');
var _search = jQuery('#tg-search');
var _inputfocus = jQuery('#tg-search > form > fieldset > input[type="search"]');
_btnsearch.on('click', function(event) {
    event.preventDefault();
    _search.addClass('open');
    _inputfocus.focus();
});
var _hidesearch = jQuery('#tg-search, #tg-search button.close');
_hidesearch.on('click keyup', function(event) {
    if (event.target == this || event.target.className == 'close' || event.keyCode == 27) {
        jQuery(this).removeClass('open');
    }
});
jQuery('form').submit(function(event) {
    event.preventDefault();
    return false;
});
/* ---------------------------------------
    CATEGORY MEGA MENU
--------------------------------------- */
var _btncategory = jQuery('#tg-btncategory');
var _category = jQuery('#tg-category');
_btncategory.on('click', function(event) {
    event.preventDefault();
    _category.slideToggle(300);
    _category.parent().toggleClass('tg-open');
});
var _btncategory2 = jQuery('#tg-btncategory2');
var _category2 = jQuery('#tg-category2');
_btncategory2.on('click', function(event) {
    event.preventDefault();
    _category2.slideToggle(300);
    _category2.parent().toggleClass('tg-open');
});
/* ---------------------------------------
    HOME PAGE SEVEN NAVIGATION
--------------------------------------- */
var _closenav = jQuery('#tg-closenav');
var _navigation = jQuery('#tg-navigation');
_closenav.on('click', function(event) {
    event.preventDefault();
    _navigation.removeClass('in');
});
});

// Console blocking
console.clear()
console.log("%cPažljivo! Ne biste trebali biti ovde. ❌❌❌ ", 




// Blocking F12
$(document).keydown(function(e){
if(e.which === 123){
   return false;
}
});

0 个答案:

没有答案