-1

我正在尝试让我的表单正常工作,但如果我发布我的表单数据,它只会刷新网站。当我登录时,登录表单应该被隐藏,但这也没有发生。

更新:仍然无法正常工作,我将值放在 URL 中,但我认为它还没有响应函数。

如果有人有teamviewer并且想通过聊天/观看帮助我,那么解决这个问题会容易得多。远程 ID:532 027 730 通行证:vsu868

我很想为那些可以帮助我的人做点什么,我是一名平面设计师,所以我可以帮助解决任何图形需求。

谢谢。

这是现在的代码:

if($_POST['submit']){
    $gbn = sha1($_POST['gbn']);
    $ww = sha1($_POST['ww']);
    if(!$gbn || !$ww){
        // Check if no data is sent. if true, message the error.
        echo "<span style='color:#F04A60;'>Geen gegevens ingevuld, probeer opnieuw.</span>";
        /*echo "<script type='text/javascript'>document.location.href='../products.php';</script>";*/
    }else{
        // Check if username exists in database.
        $res = mysql_query("SELECT * FROM customers WHERE gbn = '".$gbn."'");
        $num = mysql_num_rows($res);

        if($num == 0){
            // Message Error
            echo "<span style='color:#F04A60;'>Gebruikersnaam onjuist, probeer opnieuw.</span>";
            /*echo "<script type='text/javascript'>document.location.href='../products.php';</script>";*/
        }else{

            // We have a match!
            // Check if there is match between the username and password in the Database.
            $res = mysql_query("SELECT * FROM `customers` WHERE `username` = '".$gbn."' AND `password` = '".$ww."'");
            $num = mysql_num_rows($res);

            if($num == 0){
                // Message Error
                echo "<span style='color:#F04A60;'>Wachtwoord onjuist, probeer opnieuw.</span>";
            /*  echo "<script type='text/javascript'>document.location.href='../products.php';</script>";*/
            }else{
                //if there was continue checking
                //split all fields fom the correct row into an associative array
                $row = mysql_fetch_assoc($res);
                $_SESSION['uid'] = $row['id'];
                //show message
                echo "<script type='text/javascript'>document.location.href='../products.php?u=" . $gbn . "';</script>";
                //if they have log them in
                //set the login session storing there id - we use this to see if they are logged in 
            }
        }
    }
}

if(isset($_SESSION['uid'])){
    echo "Welcome $gbn, klik <a href='shoppingcart.php'>hier</a> om naar uw winkelwagen te gaan";
    }
    else{
    ?>
    <!-- LOG IN DIV--> 
        <div id="login">
            <form name="form2" methode="POST" action="">
                <h2>Log in</h2>
                <div>
                    <input type="text" placeholder="Username" required="" id="gbn" />
                </div>
                <div>
                    <input type="password" placeholder="Password" required="" id="ww" />
                </div>
                <div>
                    <input class="button" type="submit" value="log In" />
                    <a href="passwordhelp.php">Lost your password?</a>
                    <a href="register.php">Register</a>
                </div>
            </form><!-- form -->
        </div>
     <?php
        } 
    ?>
4

1 回答 1

2

您正在调用名称为“提交”的 $_POST,但您的按钮没有名称

尝试这个

<input class="button" type="submit" name="submit" value="log In" />
于 2013-10-29T15:39:32.487 回答