I have a problem with this insert statement, iv only been doing php for the past two days so please bare with me,
I have a mysql database which is called accounts, which has a table in it called users and im trying to insert information the user has entered into that table.
but it keeps throwing a http 500 internal server error.....
This is my Form where the user inputs the information
- Code: Select all
<html>
<head>
<title> Update Database</title>
</head>
<body>
<form method="post" action="Update.php">
FirstName:<br/>
<input type="text" name="Fname" size="30"/><br/>
LastName:<br/>
<input type="text" name="Lname" size="30"/><br/>
UserName:<br/>
<input type="text" name="UName" size="30"/><br/>
Password:<br/>
<input type="text" name="Password" size="30"/><br/>
<input type="submit" value="Create User"/>
</form>
</body>
</html>
And this is where im trying to insert the information in to the users table
- Code: Select all
<?php
$Firstname = $_POST['Fname'];
$Surname = $_POST['Lname'];
$UserName = $_POST['UName'];
$Password = $_POST['Password'];
$Valid = mysql_connect('localhost:3306' , 'root' , 'password123');
if(!$Valid)
{
echo 'Could not connect' . mysql_error();
}
else
{
mysql_select_db('accounts', $Valid) or die('could not select database');
$query = "INSERT INTO `users` (`UserName`, `Password`, `FirstName`, `Surname`) VALUES ('".$UserName."' , '".$Password."' , '".$FirstName."' , '".$Surname."')";
mysql_query($query, $Valid) or die('Error Adding the users details.');
echo "The following user " . $Firstname "has been added to the database";
}
?>
Iv attached an image which shows my database and table.....
any help would be appreciated.



