Find Article
Saturday, May 21, 2011
Php Code: Guest Book
This is the better guest book.
2 files,
1) process.php
2)index.php
//process.php starts here<?$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 guestbook VALUES ('','$first','$last','$email','$web','$comment')";mysql_query($query);mysql_close();?>//End of Process.php//start of index.php<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>//end of index.php//start of view.php<?$username="username";$password="password";$database="your_database";mysql_connect(localhost,$username,$password);mysql_select_db($database) or die( "Unable to select database");$row1 = mysql_query("SELECT * FROM guestbook")while($row=mysql_fetch_array($row1)) {echo "$row[first_name] $row[last_name] Said<br><hr>";echo "$row[comments]<br><hr>";echo "You can view $row[first_name]'s website at $row[www]";}?>//end of view.php
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment