I have the following code wich is designed to insert data into my mysql database. However the data for the users e-mail keeps ending up in the pawwsord field along with the password information...
any ideas why??
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
if(isset($username) && isset($password) && isset($username))
{
//check user input here
$dberror="";
$ret=add_to_database($username,$password.$mail,$dberror);
if(!$ret)
print "Error: $dberror<br>";
else
print"thankyou very much";
}
else
{
write_form();
}
function add_to_database( $username, $password, $mail)
{
$user="root";
$pass="";
$db="dl";
$link=mysql_connect("localhost","root","");
if(!$link)
{
$dberror="couldnt connect";
return false;
}
if(!mysql_select_db($db,$link))
{
$dberror=mysql_error();
return false;
}
$query="INSERT INTO users (username,password,mail)
values('$username','$password','$mail')";
if(!mysql_query($query,$link))
{
$dberror=mysql_error();
return false;
}
return true;
}
function write_form()
{
global $PHP_SELF;
print"<form action=\"$PHP_SELF\" method=\POST\">\n";
print"<input type=\"text\" name=\"username\">";
print"the username you would like<p>\n";
print"<input type=\"text\" name=\"password\">";
print"your password<p>\n";
print"<input type=\"text\" name=\"mail\">";
print"your mail addy<p>\n";
print"<input type=\"submit\" value=\"submit\">\n</form>\n";
}
?>
</body>
</html>
thanks in advance