-1

ログインページを作成しようとしましたが、うまくいきません。[ログイン/サインアップ] をクリックすると、ポップアップが表示されます。詳細を入力し、ログインをクリックします。何も起こりません。サインアップしようとしましたが、まだ何も起こりません。

私のホームページ

<HTML>
<HEAD>
<TITLE>Experiment on Social Network</TITLE>
<script src = "jscript.js"></script>
<link rel = "stylesheet" type = "text/css" href = "style.css" />
<script type = "text/javascript">
window.onload = function()
{
    document.getElementById("LoginBtn").onClick = sendRequest("login.php");
    document.getElementById("SignBtn").onClick = sendRequest("Signup.php");
};
</script>
</HEAD>
<BODY bgcolor = "black" text = "white" alink = "blue" vlink = "cyan">
<a href = "..//index.html">Home</a>
<div id = "responseOutput">
<a id = "logSign_pop" href = "#logSign">Login or Signup</a>
<a href = "#x" class="overlay" id="logSign"></a>
    <div class = "popup">
            <h1>Welcome Guest!</h1>
        <form action = "#">
        <h3>Login Here</h3>
        <label for = "user">Username</label>
        <br />
        <input type = "text" id = "uname" value = "" />
        <br />
        <label for = "password">Password</label>
        <br />
        <input type = "password" id = "pass" value = "" />
        <br />
        <input type="button" id = "LoginBtn" value="Log In" />
        <a class="close" href="#close"></a> 
    </form>
    <form action = "#">
        <h3>Sign Up</h3>
            <label for="firstName">First Name</label>
            <br/>
            <input type="text" id="firstName" value="" />
            <br />
            <label for="lastName">Last Name</label>
            <br/>
            <input type="text" id="lastName" value="" />
            <br />
            <label for="useName">UserName</label>
            <br/>
            <input type="text" id="useName" value="" />
            <br />
            <label for="email">Email</label>
            <br/>
            <input type="text" id="email" value="" />
            <br />
            <label for="pass">Password</label>
            <br/>
            <input type="password" id="pwd" value="" />
            <br />
        <input type="button" id = "SignBtn" value="Sign Up" />
        <a class="close" href="#close"></a>
    </form>
</div>
 </div>
<br/>
<center>
<h1>Welcome to MaxZeroEdge Network</h1>
</center>
</BODY>
</HTML>

login.php

<?php
$logID = $_POST["uname"];
$pass = $_POST["pass"];
$login = 0;
$con = mysql_connect("localhost","admin","admin");
    if (!$con)
        {
            die('Could not connect to database: '. mysql_error());
        }

    $db = mysql_select_db("logDat", $con);
    if(!$db)
    {
        create_db();
    }

    $tb = "SELECT * from logDat";
    $av = @mysql_query($tb);
    if(!$av)
    {
        echo "Error creating database: " . mysql_error();
    }
    else
    {
        checkLogin();
    }

function checkLogin()
    {
        //Checks if a particular value exists
        $result = mysql_query("SELECT * FROM logDat");
        //$passResult = mysql_query("SELECT password FROM logDat");
        $check = $logID;
        while($login == 0 && $row = mysql_fetch_array($result))
        {
            if($row["Username"] == $logID)
            {
                if($row["password"] == $logPass)
                {
                    /*$login = 1;
                    $expire = 86400*7;
                    setcookie("user",$logID,$expire);*/
                    $_SESSION["userid1"] = $logID;
                    print "<message>Welcome $logID</message>";
                    //header("Location: Social Network.php"); // redirects
                }
                else echo "Incorrect Password.";
            }
            else echo "User doesn't exist.";
        }
    }

    //Runs for the first time only. Creates the database    

    function create_db()
    {
        if (mysql_query("CREATE DATABASE logDat",$con))
        {
            echo "Database created";
        }
        else
        {
            echo "Error creating database: " . mysql_error();
        }
    }   

//Runs for the first time only. Creates the table.

    function create_table()
    {
        //Password varchar(20),
        $user = "CREATE TABLE logDat
        (
            personID int NOT NULL AUTO_INCREMENT,
            PRIMARYKEY(personID),
            Username varchar(20),
            FirstName varchar(50),
            LastName varchar(50),
            Email varchar(100),
            password varchar(20);
        )";
        mysql_query("INSERT INTO logDat(PRIMARYKEY, Username, FirstName, LastName, Email, password) VALUES(0, 'zero', 'Palash', 'Max', 'maxzeroedge@gmail.com', 'hellfire') ");
    }

mysql_close($con);  
?>
4

1 に答える 1

1

JavaScriptwindow.onload関数を削除する

ボタンの入力タイプsubmitを使用し、対象ページを追加しますaction

として:

<form action = "login.php" method='post'>

<input type="submit" id = "LoginBtn" value="Log In" />

それ以外の

<form action = "#">

<input type="button" id = "LoginBtn" value="Log In" />

申し込んだ部分も同じ

于 2013-09-22T12:15:06.533 に答える