PHP Message Board

Source: Internet
Author: User

/************/
config.php
/***********/
<?php
$host = ' localhost '; Database server
$user = ' root '; Database user Name
$password = ' 123456 '; Database Password
$db = ' project '; Database name

Open Database
$conn = Mysql_pconnect ($host, $user, $password);
if (! $db)
{
Die (' <b> database connection failed!</b> ');
}
Select Database
mysql_select_db ($DB);
?>
/*********************/
index.php
/********************/


<body>
<script type= "Text/javascript" >
function Check_form (obj) {
if (document.getElementById (' Post_name '). value== ') {
Alert (' Write your name on it ');
document.getElementById (' Post_name '). focus ();
return false;
}
if (document.getElementById (' Post_body '). value== ') {
Alert (' Not to spoil the bar, write the content of the message! ');
document.getElementById (' Post_body '). focus ();
return false;
}
return true;

}
</script>
<form action= "/sent.php" method= "POST" onsubmit= "return Check_form" >
<table width= "100%" border= "0" >
<tr>
&LT;TD align= "Right" > Your name </td>
<td><input name= "Post_name" id= "Post_name" type= "text" size= "maxlength=" ></td>
</tr>
&LT;TD align= "Right" > Your speech </td>
<td><textarea name= "Post_body" id= "Post_body" rows= "ten" cols= "M" > your statement </textarea></td>
<tr>
&LT;TD align= "right" > </td>
<td><input type= "Submit" name= "Submission" value= "submitted" ></td>
</tr>
</table>
</form></td>
</body>

<?php
Include (' get.php ')
?>
/***************************/
get.php
/****************************/
[Quote]
<?php
Include (' config.php ');
$query = "SELECT * from Project_post";
$result = mysql_query ($query);

while ($row = Mysql_fetch_array ($result)) echo "Name: $row [Post_name] </br> content: $row [post_body]</br>";
?>
/***************************/
sent.php
/***************************/

<?php
Include (' config.php ');
$post _name=addslashes ($_post[' post_name '));
$post _body=addslashes ($_post[' post_body '));
$sql = "INSERT into Project_post (post_name,post_body) VALUES (' $post _name ', ' $post _body ')";
mysql_query ($sql);
Header (' location:/index.php ');
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.