0

I have this next code

<!doctype html>

<html class="">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Nieuwe gebruiker | Sociale buurt</title>
<link href="boilerplate.css" rel="stylesheet" type="text/css">
<link href="onzebuurt.css" rel="stylesheet" type="text/css">

<script type="text/javascript" language="javascript">

function formulierValideren() {     
        if (document.getElementById('Username').value == '' || document.getElementById('Username').value == null)
        {
            alert ('Gebruikersnaam is verplicht.');
            document.getElementById('Username').style.borderColor = "red";
            return false;
        }
        else if (document.getElementById('Wachtwoord').value == '' || document.getElementById('Wachtwoord').value == null)
        {
            alert ('Wachtwoord is verplicht.');
            document.getElementById('Wachtwoord').style.borderColor = "red";
            return false;
        }
        else if (document.getElementById('Wachtwoord2').value == '' || document.getElementById('Wachtwoord2').value == null)
        {
            alert ('Bevestig wachtwoord.');
            document.getElementById('Wachtwoord2').style.borderColor = "red";
            return false;
        }
        else if (document.getElementById('Wachtwoord2').value != document.getElementById('Wachtwoord').value)
        {
            alert ('Wachtwoorden komen niet overeen.');
            document.getElementById('Wachtwoord2').style.borderColor = "red";
            return false;
        }
        else
        {
            $("#bevestig").click(function() {
                gebruikerToevoegen();
            });

            var msg = "Registratie succesvol. Klik op OK om u aan te melden op de site.";
            if(confirm(msg)){
            setTimeout(function() {window.location.href = "http://webs.hogent.be/kevinbaeyens/"})
            }
        }
        //end if
}//end function

function gebruikerToevoegen() {
var request = new XMLHttpRequest();
request.open("POST", url);
request.onload = function() {
    if (request.status == 201){
        alert("everything OK!");
    } else {
        alert("you're wrong");
    }
};
}

</script>
</head>
<body class="body2">
<div class="gridContainer clearfix">
<div class="header1">
    <center>    
    Nieuwe gebruiker
    </center>
</div>
    <div id="formulier2">
        <form method="post" name="form" action="">
            <p class="labels"><center>Gebruikersnaam *</center></p><input id="Username" type="text" name="Username" placeholder="Gebruikersnaam" size="50">
            <p class="labels"><center>Wachtwoord *</center></p><input id="Wachtwoord" type="password" name="Wachtwoord" placeholder="Wachtwoord" size="50">
            <p class="labels"><center>Bevestig wachtwoord *</center></p><input id="Wachtwoord2" type="password" name="Bevestig wachtwoord" placeholder="Bevestig wachtwoord" size="50">
            <br />
            <a href="index.html" style="text-decoration:none"><center><img id="return" name="jsbutton" src="return.png" alt="Terug" /></center></a>
            <br />
            <center><input id="bevestig" type="image" src="Bevestig.png" width="200"  height="50" border="0" alt="SUBMIT!" onclick="formulierValideren()"></center>
            <br />
        </form>
    </div>
</div>
</body>
</html>

I want to send the data from #Username and #Wachtwoord to my MySQL database. Please help me please, i'm stuck on this for almost a week now. i'll be so happy if anyone could help me! if i need to give more information, please ask me

4

2 回答 2

0

1)你为什么使用框架(似乎是 jQuery)并做这样的事情

var request = new XMLHttpRequest();

你可以看看:http ://api.jquery.com/jQuery.ajax/

2) 建议使用 e.preventDefault 而不是在验证时返回falsehttps://developer.mozilla.org/en-US/docs/DOM/event.preventDefault

3)你在你的“行动”中做什么?或者:您的网址指向哪里?如前所述:您需要在服务器端使用某种“端点”:

http://www.springsource.org/

http://www.asp.net/

http://rubyonrails.org/

https://www.djangoproject.com/

http://framework.zend.com/

http://www.catalystframework.org/

http://www.seaside.st/

管他呢

于 2013-04-30T22:38:55.693 回答
0

首先,我以为您正在寻找客户端解决方案(无论如何这将是一个非常糟糕的主意)。杰森是对的。但是如果你想要一些自动的东西,看看 smarty php。不过,首先你必须学习一些基本的东西和一个非常清晰的例子,你可以在这个视频教程中找到: http ://www.youtube.com/watch?v= gvGb5Z0yMFY

于 2013-04-30T21:29:09.667 回答