scriptreg.js:
Register.html:
register.php:
[CODE]<?php
if(isset($_GET['vorn']) && isset($_GET['name']) && isset($_GET['benu']) && isset($_GET['pass']) && isset($_GET['passw']) && isset($_GET['adre']) && isset($_GET['post']) && isset($_GET['ort']) && isset($_GET['emai']) && isset($_GET['emaiw']))
{
$benu = $_GET['benu'];
$pass = $_GET['pass'];
$emai = $_GET['emai'];
if($benu == $benu)
{
$sess[0][login] = "valid" ;
$sess[0][name] = $benu;
setcookie("username",$benu,time()+(3600*24));
$true = json_encode($sess);
echo $true;
}
else
{
$err[0][login] = "invalid";
$err[0][code] = "40";
$false = json_encode($err);
echo $false;
}
}
else
{
$err[0][login] = "invalid";
$err[0]
Hab ich da vergessen den Button zu verlinken? Warum geschieht keine Interaktion bei einem Klick auf den Speicher Button.
Code:
$(document).ready(function(){ $("#button").on("click", function() { var vorn = $("#vorname").val(); var name = $("#name").val(); var benu = $("#benutzername").val(); var pass = $("#passwort").val(); var passw = $("#passwortw").val(); var adre = $("#adresse").val(); var post = $("#postleitzahl").val(); var ort = $("#ort").val(); var emai = $("#email").val(); var emaiw = $("#emailw") if() { $.ajax ( { type: "GET", url: "register.php", data: { benutzername: benutzername, passwort: passwort }, dataType: "json", success: function(response) { if(response==true) { window.location.replace("main.html"); } else { console.log(response); alert("Username oder Passwort falsch"); } } } ); } } else { alert('Bitte fuellen Sie alle Felder aus!'); } }); });
Code:
<html> <head> <title> Register </title> <link rel="stylesheet" type="text/css" href="new2.css"> <script type="text/javascript" src="jquery-2.1.0.min.js"></script> <script type="text/javascript" src="scriptreg.js"></script> </head> <body> <div id="div12"> </br> <div id="div11">  <div id="zentral1"> <div id="uberschrift"> Registrieren<table><tr><td> </td></tr></table> </div> <table id="tabelle"> <tr> <th>Vorname:</th> <th><input type="text" name="vorname" id="vorname" placeholder="Max" class="normal" maxlength="10"></th> <th>       </th> <th>Adresse:</th> <th><input type="text" name="adresse" id="adresse" placeholder="Am Kirschbaum 1" class="normal" maxlength="30"></th> </tr> <tr> <th>Name:</th> <th><input type="text" id="name" name="name" placeholder="Mustermann" class="normal" maxlength="10"></th> <th>       </th> <th>Postleitzahl:</th> <th><input type="text" id="postleitzahl" name="plz" placeholder="12345" class="normal" maxlength="5"></th> </tr> <tr> <th>Benutzername:</th> <th><input type="text" id="benutzername" name="benutzername" placeholder="mm12345" class="normal"></th> <th>       </th> <th>Ort:</th> <th><input type="text" name="ort" id="ort" placeholder="Los Angeles" class="normal" maxlength="20"></th> </tr> <tr> <th>Passwort:</th> <th><input type="password" id="passwort" name="passwort" placeholder="*********" class="normal" maxlength="10"></th> <th>       </th> <th>EMail:</th> <th><input type="text" id="email" name="email" placeholder="max@anbieter.de" class="normal" maxlength="20"></th> </tr> <tr> <th>Passwort wdh.:</th> <th><input type="password" id="passwortw" name="passw" placeholder="*********" class="normal" maxlength="10"></th> <th>       </th> <th>EMail wdh.:</th> <th><input type="text" id="emailw" name="e-mail" placeholder="max@anbieter.de" class="normal" maxlength="20"></th> </tr> </table> </br> <div> <input type="button" name="button" id="button" class="button" value="Speichern"> </div> </div> </div> </div> </body> </html>
[CODE]<?php
if(isset($_GET['vorn']) && isset($_GET['name']) && isset($_GET['benu']) && isset($_GET['pass']) && isset($_GET['passw']) && isset($_GET['adre']) && isset($_GET['post']) && isset($_GET['ort']) && isset($_GET['emai']) && isset($_GET['emaiw']))
{
$benu = $_GET['benu'];
$pass = $_GET['pass'];
$emai = $_GET['emai'];
if($benu == $benu)
{
$sess[0][login] = "valid" ;
$sess[0][name] = $benu;
setcookie("username",$benu,time()+(3600*24));
$true = json_encode($sess);
echo $true;
}
else
{
$err[0][login] = "invalid";
$err[0][code] = "40";
$false = json_encode($err);
echo $false;
}
}
else
{
$err[0][login] = "invalid";
$err[0]
Code:
= "404"; $false = json_encode($err); echo $false; } ?>
Kommentar