Hello all,
I hope you are doing great.I am using phpmyadmin for the first time.So I created a table called guestbook with 4 attributes: id,name,email,message..Then I created a php file with the following code (saved in htdoc in Xampp folder)and html form which would take the data from the user and insert into the database which could later be retrieved.So far I have just written the insertion code which successfully creates the form but when I click on submit button it opens the same php file with the code and no insertion is made in the database..here is my code..plz help me urgently..i have my project deadline very soon.
php file called guest.php:
<?php
$user="root";
$password="";
$database="Guestbook";
$name=$_POST['name'];
$email=$_POST['email'];
$body=$_POST['body'];
$connect("localhost",$user,$password);
mysql($connect);
@mysql_select_db($database)or die("unable to select db");
$query = mysql_query("INSERT INTO Guestbook(id,name,email,body) VALUES('','$name','$email','$body')");
if(!$query)
{
echo mysql_errno().':'.mysql_error();
}
mysql_close();
?>
html file called new.html:
<html>
<head>
<title>Guestbook</title>
</head>
<body>
<form method="post" action="guest.php" >
Name:<input type="text" name="name" size="30"/><br/>
Email: <input type="text" name="email" size="30"/><br/>
<p>Text:<br/>
<textarea name="message" rows="15" cols="60"></textarea></p>
<br/>
<input type="submit" value="Submit"/>
<input type="reset" value="Clear"/>
</form>
</body>
</html>