You only need 2 files, a process.php and a index.php.
What does process.php do? Well it connects to your mysql database. here's the code for it:
- Code: Select all
<?
$username="username";
$password="password";
$database="your_database";
$first=$_POST['first'];
$last=$_POST['last'];
$email=$_POST['email'];
$web=$_POST['web'];
$comment=$_POST['comment'];
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "INSERT INTO contacts VALUES ('','$first','$last','$email','$web','$comment')";
mysql_query($query);
mysql_close();
?>
And what about index.php? Well here you have the form such as First name,last name ect., you know probably how a form looks like, so let's get the code here:
- Code: Select all
<html>
<head>
<title>Guest Book</title>
</head>
<body>
<form action="process.php" method="post">
First Name: <input type="text" name="first"><br>
Last Name: <input type="text" name="last"><br>
E-mail: <input type="text" name="email"><br>
Web: <input type="text" name="web"><br>
Comments: <textarea rows="6" name="comment" cols="27"></textarea>
<input type="Submit">
</form>
</body>
</html>[/code]
And that's it, you've just created your own guestbook, hurray, you've got any questions don't hesitate to msg me ;)
Greetz knedl.





