
02-Apr-2008, 14:15
|
|
New Member
|
|
Join Date: Jun 2007
Posts: 20
|
|
|
problem in sending data to the database
PHP Code:
<html>
<body>
<?php
if(isset($_POST['Insert']))
{
// This is the name of the database i made.
$db = mysql_connect("localhost","root","") or die('connection error '.mysql_error());
//
mysql_select_db('mybase',$db) or die('selection error '.mysql_error());
$login=$_POST['login'];
$password=$_POST['password'];
$first=$_POST['first'];
$last=$_POST['last'];
$Email=$_POST['Email'];
//
$sql = "INSERT INTO user (login,first,last,password,Email) VALUES('$login','$password','$first','$last','$Email')"; // on insère les informations du formulaire dans la table
mysql_query($sql) or die('Error !'.$sql.'<br>'.mysql_error());
//
mysql_close(); // close the connection
echo 'a new user has benn added.';
}
else
{
?>
<form method="POST">
Login:<br><input type="text" name="login" id="login"><br>
Password:<br><input type="text" name="password" id="password"><br>
First name:<br><input type="text" name="first" id="first"><br>
Last name:<br><input type="text" name="last" id="last"><br>
E-mail:<br><input type="text" name="Email" id="Email"><br>
<br><input type="submit" value="Insert" id="Insert"><br>
</form>
<?php
}
?>
</body>
</html>
|
|