CODE:
- Code: Select all
<?php
//connect to MYSQL
$connect=mysql_connect("localhost","***","***") or die ("sorry unable to connect(1)".mysql_error());
//select database
$DB=mysql_select_db(tut_site, $connect) or die ("sorry unable to select DB".mysql_error());
//setting-up query
$query="INSERT INTO `users` (`id`, `user`, `password`, `email`, `website`, `joined`, `age`, `interests`, `desc`) VALUES ('', '$_POST[user]', '$_post[password]', '$_POST[email]', '$_POST[website]', '', '$_POST[age]', '$_post[interests]', '$_post[desc]')";
//sending query to server, if error, MYSQL will break out of query and send error to browser
mysql_query($query) or die ("Sorry unable to connect(2)".mysql_error());
//informing user of success
echo("Your user:<b>$_POST[user]</b>, was created");
?>
HTML Form
- Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Create New User</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body text="#FF0000">
<p><font face="Arial Black, Comic Sans MS">Please fill in the below from and your
account will be created:</font></p>
<p><font face="Arial, Helvetica, sans-serif">All fields mark with a * <strong>must</strong>
be filled in </font></p>
<form name="Create User" method="post" action="create.php">
<p>&</p>
<table width="75%" height="343" border="0" cellspacing="2">
<tr>
<td width="18%">User Name:*</td>
<td width="82%"><input type="text" name="username"></td>
</tr>
<tr>
<td>Password: *</td>
<td><input type="text" name="password"></td>
</tr>
<tr>
<td>Website</td>
<td><input type="text" name="website"></td>
</tr>
<tr>
<td>Age</td>
<td><input type="text" name="age"></td>
</tr>
<tr>
<td>Interests</td>
<td><input type="text" name="interests"></td>
</tr>
<tr>
<td>Description</td>
<td><textarea name="desc" cols="50" rows="10"></textarea></td>
</tr>
</table>
<table width="75%" border="0" cellspacing="2">
</table>
<p>
<input name="Submit" type="submit" value="Create">
</p>
<p>&</p>
</form>
<p>&</p>
</body>
</html>
cany anybody help, as i cant see a problem

