Jump to content

Question about a redirection with jQuery


ericblanc

Recommended Posts

Hi, here's my problem, i've built a login form which is using jquery validation. The jQuery function calls a php file (with ajax), the php file check if the member exists and it returns an echo if the login is successfull or not. The problem is that now I don't want to make an echo but more like a Header: Location (redirection). My page doesn't load complety, in fact, only the bottom part is redirecting.

 

loginform.html

<script type="text/javascript"  charset="utf-8">
    jQuery(function() {
        // show a simple loading indicator
        var loader = jQuery('<div id="loader"><img src="images/loading.gif" alt="loading..." /></div>')
            .css({position: "relative", top: "1em", left: "25em"})
            .appendTo("body")
            .hide();
        jQuery().ajaxStart(function() {
            loader.show();
        }).ajaxStop(function() {
            loader.hide();
        }).ajaxError(function(a, b, e) {
            throw e;
        });
       
        jQuery("#form").validate({
            submitHandler: function(form) {
                jQuery(form).ajaxSubmit({
                    target: "#result"
                });
            },
           
            rules: {
            user: {
                required: true,
                email: true
            }
        },
        messages: {
            user: "Veuillez entrer un courriel valide"
        }
        });
    });
</script>

</head>
<body>

<h1 id="banner">Module Membre</h1>
<div id="main">

<form method="post" class="cmxform" id="form" action="formloginmember.php">
    <fieldset>
        <legend>Connexion</legend>
        <p>
            <label for="user">Courriel</label>
            <input id="user" name="user" class="required"/>
        </p>
        <p>
            <label for="pass">Password</label>
            <input type="password" name="password" id="password" class="required" minlength"5" />
        </p>
        <p>
            <input class="submit" type="submit" value="Login"/>
        </p>
    </fieldset>
    <input type="hidden" name="type" value="profile">
</form>

<div id="result"></div>

 

 

formloginmember.php

<?php
session_start();
ob_start();
include("config.php");
usleep(500000);
$MemberEmail = $_REQUEST['user'];
$MemberPassword = md5($_REQUEST['password']);
$LoginType = $_REQUEST['type'];

$r = connectMember($MemberEmail, $MemberPassword);
if ($r == 1)
{
    echo "<font color=green>Connexion rèussi</font>";
}
else
{
    echo "<font color=red>Échec de connexion</font>";
}
if ($LoginType == "profile")
{
    header("Location: index.html");
}

 

Thanks !

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.