Then when I go to the temp site I've made, http://localhost/Hjemmeside/index.php, it works all fine. I write in all the inputs, and when i submit, it seems to work fine, it tells me if the passwords don't match etc. BUT it ALWAYS outputs this first:
Notice: Use of undefined constant username - assumed 'username' in [text]C:\xampp\htdocs\Hjemmeside\register.php on line 4
Notice: Use of undefined constant password - assumed 'password' in C:\xampp\htdocs\Hjemmeside\register.php on line 5
Notice: Use of undefined constant password2 - assumed 'password2' in C:\xampp\htdocs\Hjemmeside\register.php on line 6
Deprecated: Function eregi() is deprecated in C:\xampp\htdocs\Hjemmeside\register.php on line 9
Notice: Use of undefined constant password - assumed 'password' in C:\xampp\htdocs\Hjemmeside\register.php on line 26
Notice: Use of undefined constant password2 - assumed 'password2' in C:\xampp\htdocs\Hjemmeside\register.php on line 26[/text]
I have this index.php page:
Code: Select all
<!--#include file="header.html"-->
<form action="register.php" method="post">
<p>Brugernavn: <br> <input type="text" name="username" size="20" maxlength="30" value=""></p>
<p>E-mail: <br> <input type="text" name="email" size="20" maxlength="50"></p>
<p>Kodeord: <br> <input type="password" name="password" size="20" maxlength="30"></p>
<p>Skriv kodeord igen: <br> <input type="password" name="password2" size="20" maxlength="30"></p>
<p><input type="submit" name="submit" value="Opret Bruger"></p>
</form>
<!--#include file="bottom.html"-->Code: Select all
<?php
include('config.php');
$test = $_POST[username]; //Line 4
$pass = $_POST[password]; //Line 5
$pass2 = $_POST[password2]; //Line 6
//alphanumeric
if (!eregi("([^A-Za-z0-9])", $test)) { //Line 9
//duplicate names
$query = "SELECT * FROM users WHERE username ='$_POST[username]'";
$result = mysql_query($query);
$num = mysql_num_rows($result);
if ($num == 0){
}else{
error("Brugernavn er allerede i brug.");
}
} else {
error("Du må kun bruge bogstaver og tal.");
}
if ($_POST[password] != $_POST[password2]) { //Line 26
error("Kodeordene er ikke ens.");
}
//ERROR FUNCTION
function error($t) {
echo "<p style='color:red'>" . $t . "</p>";
include('index.php');
}
?>Code: Select all
<?php
$host="localhost";
$username="root";
$db_name="database";
//connecting
mysql_connect($host, "$username")or die("cannot connect to server");
mysql_select_db("$db_name")or die("cannot connect to DB");
?>Thanks in advance!