Hi all
could any one what is wrong with the following code, I tried to create user authorisation to add new user to the database the problem is does not add the username and password to the database, which I created with one table called user and does not say whether or not added I did checked the table only the id incremented with empty (without username and password).
Thank you,
PHP Code:<?php include "header.php"; ?>
<?php
$self= $_server['php_self']; #assigning value
$username =$_post['username'];
$password =$_post['password'];
if((!$username) and (!$_password))
{
$form="please enter all your details";
# writting the form
$form.="<form action=\"$self\" ";
$form.= "method=\"post\"> User Name: ";
$form.="<input =\"text\" name = \"username\" ";
$form.= "value\"username\"><br><br> Password:";
$form.="<input =\"password\" name = \"password\"";
$form.= "value\"password\"><br><br>";
$form.="<input type = \"Submit\" value =\"Submit\">";
$form.="</form>";
echo($form);
}
else
{
//connect to MySQL
$conn = mysql_connect("localhost","root","")
or die("Could not connecte");
//select the database
$db= mysql_select_db( "my_database", $conn)
or die("Could not select database");
//create SQL query
$sql="insert into user (username,password) values ('$username','$password')";
//excute the query
$rs= mysql_query($sql,$conn)
or die("Could not excute query");
if($rs)
{
echo("New user $username added" );
}
}
?>




Reply With Quote