LiveZilla Live Help
 


Go Back   Chime Host - Web Hosting Forum > World Wide Web > Programming / Scripting / Coding Forum > PHP
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

PHP The most widely used server-side programming language for web applications.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-08-2008, 09:13 PM
Junior Member
 
Join Date: Jun 2008
bokepwap is on a distinguished road
Default [php] simple shout script with mysql database

juat simple script with database MySQL

first you need make a table in your mysql database
for example, table name is contoh_tabel_shout.
make this table with PHPMyAdmin
PHP Code:
 CREATE TABLE `contoh_tabel_shout` (
`
idINT11 UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`
usernameCHAR32 NOT NULL ,
`
timeINT11 NOT NULL ,
`
textTEXT NOT NULL
ENGINE MYISAM 
there are 4 fields:
- id
- username
- time
- text
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-08-2008, 09:14 PM
Junior Member
 
Join Date: Jun 2008
bokepwap is on a distinguished road
Default

This is the shout.php script code:

Code:
<?php
$serper_host = 'localhost'; // database host
$serper_username = 'username_database'; // database username
$serper_password = 'password_database'; // database password
$serper_database = 'nama_database'; // database name
$nama_tabel = 'contoh_tabel_shout'; // database table name

mysql_connect($serper_host, $serper_username, $serper_password)
or die("Could not connect: " . mysql_error());
mysql_select_db($serper_database);


if ($_SERVER['REQUEST_METHOD']=='POST')
{
$username = htmlspecialchars(addslashes(stripslashes($_POST['username'])));
$text = htmlspecialchars(addslashes(stripslashes($_POST['text'])));
$query = mysql_query("
INSERT INTO $nama_tabel
(username, time, text)
VALUES
('$username', ".time().", '$text')
");
if (!$query)
{
die ("Ga bisa masukin post baru".mysql_error());
exit;
}
}

$result = mysql_query("
SELECT username, time, text
FROM $nama_tabel
ORDER BY time DESC
LIMIT 0,5
");
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
printf("%s [%s]: &nbsp;
%s
<br/>
",
$row['username'],
gmdate('d m/H:i', $row['time']+(7*3600)),
$row['text']
);
}
?>
<br/><br/>
<form action="<?=$_SERVER['PHP_SELF']?>?" method="post">
<div>
Username:<br/><input type="text" name="username" size="16"/>
<br/>
Text:<br/><input type="text" name="text" size="40"/>
<br/>
<input type="submit" value="Shout!"/>
</div>
</form>
<?php
mysql_free_result($result);
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Search Function in Other Websites? cheece2007 SEO - Search Engine Optimization 0 02-17-2010 03:06 PM
Java program for a match making company (Beginner)? JasperCalmsMe Programming / Scripting / Coding Forum 0 01-26-2010 01:11 AM
i dont think my sim has unlimited internet on my iphone? Rose Apple Iphone 0 01-04-2010 10:27 PM
my laptop says this computer was disconnected from 'network' because of user... LauraLouise Networking, Internet Access, Wireless, Mobile, Wi-Fi 0 12-31-2009 03:32 AM


All times are GMT +1. The time now is 11:13 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright ChimeHost, a Profuse Solutions LLC company