/************/
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>
<TD align= "Right" > Your name </td>
<td><input name= "Post_name" id= "Post_name" type= "text" size= "maxlength=" ></td>
</tr>
<TD align= "Right" > Your speech </td>
<td><textarea name= "Post_body" id= "Post_body" rows= "ten" cols= "M" > your statement </textarea></td>
<tr>
<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 ');
?>