Ich versuche Werte in das Array (in account.html) mit diesem Formular zuzuordnen:
<form name="register" action="register.php" method="post">
<label for="username">Username:</label> <input type="text" name="username" class="textb" maxlength="30"/><br /><br>
Password : <input type="password" name="password1" class="textb"/><br /><br>
Re-Type Password: <input type="password" name="password2" class="textb"/><br /><br>
<br>
<input type="submit" name="Create Account" value="Create Account" class="texta" />
</form>
Aber wenn ich versuche, sie hier zu nennen (im Register. php):
$username = $_POST["username"];
$password1 = $_POST["password1"];
$password2 = $_POST["password2"];
bekomme ich nur:
Notice: Undefined index: username in C:\xampp\htdocs\register.php on line 3
Notice: Undefined index: password1 in C:\xampp\htdocs\register.php on line 4
Notice: Undefined index: password2 in C:\xampp\htdocs\register.php on line 5
Kann jemand etwas Licht, warum Das Formular wird die Variablen nicht veröffentlichen?
ist die vollständige register.php Datei:
<?php
$username = $_POST["username"];
$password1 = $_POST["password1"];
$password2 = $_POST["password2"];
if($password1 != $password2)
header("location:register.php");
if (strlen($username) > 30)
header("location:register.php");
$dbhost = 'localhost';
$dbname = 'test';
$dbuser = 'root';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname, $conn);
$username = mysql_real_escape_string($username);
$query = "INSERT INTO members (username, password)
VALUES ('$username', '$password1');";
mysql_query($query);
mysql_close();
header('Location: index.php');
?>
Hier wird die volle account.html Datei:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Video for Education Log In</title>
<link rel="stylesheet" type="text/css" href="style1.css" />
</head>
<body>
<div id="wrapper">
<div id="header">
<div id="logo">
videoedu.edu </div>
<div id="menu">
<ul>
<li><a href="index.html" class="menua">Home</a></li>
<li><a href="about.html" class="menua">About Us</a></li>
</ul>
</div>
</div>
<br><br><br><br>
<div id="page">
<div id="content">
<h2>Create an Account. It's free and lets you share and watch streamed educational video content.</h2>
<h3>Simply fill out the form below.....</h3>
<div class= "form">
<form name="register" action="register.php" method="post">
<label for="username">Username:</label> <input type="text" name="username" class="textb" maxlength="30"/><br /><br>
Password : <input type="password" name="password1" class="textb"/><br /> <br>
Re-Type Password: <input type="password" name="password2" class="textb"/> <br /><br>
<br>
<input type="submit" name="Create Account" value="Create Account" class="texta" />
</form>
</div>
</div>
</div>
</div>
</body>
</html>
Gibt es irgendetwas in der Post überhaupt vorhanden? Was sind die Ergebnisse, wenn Sie var_dump ($ _ POST) ausführen? von dem Code, den Sie gepostet haben, sollte dies gut funktionieren. – GSto
greifen Sie auf Ihren folgenden Code zu: $ username = $ _POST ["username"]; $ passwort1 = $ _POST ["passwort1"]; $ passwort2 = $ _POST ["passwort2"]; 'in' register.php' Datei? –
Funktioniert es, $ _POST zu $ _GET und method = "post" zu method = "get" zu ändern? –