hi ,
Im new to php and am trying to send form data to a database
when i click my submit button though all i get is “”; } ?> "
Ilooked at my coding but cant see whats wrong _i suspect my mysql/php config maybe? any ideas?
HTML
<html>
<head>
<title> PHP and FORMS </title>
</head>
<body>
<h3>Enter your details into the form and when you are ready click the submit button </h3>
<form method="post" action="databases.php">
Given Name: <input type="text" name="gname" size = "40">
Last Name: <input type="text" name ="fname" size="40">
<br>
Email: <input type="text" name="email" value=username@domain.com>
<br>
Comments: <input type ="textarea" name="comments" rows="4" cols="20"></textarea>
<br>
<input type="submit" name="submit" value= "Submit">
<input type ="reset" name="reset" value ="Reset">
</form>
</body>
</html>
PHP
<?php
//1. Create a database connection (baza= root folder pass = password)
$connection = mysql_connect("localhost","root","pass");
if(!$connection){
die("Database connection failed: ". mysql_error());
}
//2. Select a database to use
$db_select = mysql_select_db("baz", $connection );
if(!$db_select){
die("Database selection failed: " . mysql_error());
}
?>
<html>
<head>
<title>Basic</title>
</head>
<body>
<?php
//3. Perform databse query
$result = mysql_query("SELECT * FROM customers",$connection);
if(!$result){
die("Database connection failed: ". mysql_error());
}
//4. Use returned Data
while($row = mysql_fetch_array($result)){
echo $row[1]." ".$row[2]."<br />";
}
?>
</body>
</html>
<?php
//5. Close Connection
mysql_close($connection);
?>