Scripts
Simpel nieuwsysteem! V 1.01
Dit is een simpel nieuw systeem met een delete functie! Zeer mooi gescript en een schitterende css! Als er geen berichten zijn een speciale text! Binnekort een nieuwe versie met Edit, Input velden, en beveiligd!
simpel-nieuwsysteem-v-101
CSS:
[code]/*Default setup*/
body {
font-family: arial, helvetica, sans-serif;
font-size: 11px;
color: 000000;
padding: 10px 10px 10px 10px;
marig-left: 1px;
}
td {
font-family: arial, helvetica, sans-serif;
font-size: 11px;
color: 777777;
}
td.sender {
color: #000000;
}
div.container {
border-bottom: 1px solid #69c;
border-top: 1px solid #69c;
vertical-align: middle;
}
div.content {
border-bottom: 1px solid #69c;
}
p {
font-family: arial, helvetica, sans-serif;
font-size: 11px;
color: 3D3D3D;
margin-left: 2px;
}
p.footer {
text-align: center;
}
/*Link setup*/
a:link {
color: #3D3D3D;
font-family: arial, helvetica, sans-serif;
font-size: 11px;
text-decoration: none;
border: none;
}
a:visited {
color: 666666;
font-family: arial, helvetica, sans-serif;
font-size: 11px;
text-decoration: none
}
a:active {
color: 03BBFF;
font-family: arial, helvetica, sans-serif;
font-size: 11px;
text-decoration: none
}
A:hover {
text-decoration: none;
color: #3399FF;
}
/*Fieldset.../*/
fieldset {
border: 1px solid #222222;
border-width: thin;
width: 250px;
height: auto;
-moz-border-radius:4px;
-moz-box-sizing: border-box;
}
legend {
border: 1px solid #69c;
-moz-border-radius:4px;
-moz-box-sizing: border-box;
}
textarea {
border: 1px solid #222222;
}
/*Form setup*/
input {
border: 1px solid #222222;
}
select {
border: 1px solid #69c;
-moz-border-radius:4px;
-moz-box-sizing: border-box;
}
/*List setup*/
ul {
list-style: none;
}
li {
float: right;
border-right: solid 1px #A75300;
padding-right: 8px;
margin-right: 8px;
}
/*Images*/
img {
border: none;
}
/*Text*/
h1 {
color: #787878;
}
.header {
font-size: 18px;
border-bottom: 1px solid #69c;
color: #777777;
}
.text {
color: #006699;
}
.headertext {
color: #006699;
font-size: 12px;
}
/*End CSS*/[/code]
De file zelf:
[code]<title>Nieuws-Systeem</title>
<link href="css/css.css" rel="stylesheet" type="text/css" />
<?php
include('config/data.php');
$index = "index.php";
$footer = "Hier uw footer";
echo "<div align='center' class='container'><br>
<span class='headertext'>[</span> <span class='header'>NIEUWS<span class='headertext'>-</span>SYTEEM</span><span class='headertext'> ]</span><br><br>";
//Berichten weergeven + tellen
$result = mysql_query("SELECT * FROM messages ORDER BY id DESC");
$count = mysql_num_rows($result);
// als 0 berichten is.
if($count == 0){
echo "<div align='center'>";
echo "<table width='500' border='0' cellspacing='5'>";;
echo "<tr>";
echo "<td align='left' width='75'> </td>";
echo "<td align='center' width='350' class='text'>No messages yet!<br><hr color='#222222' width='350px' size='1'></td>";
echo "<td width='75'> </td>";
echo "</tr>";
echo "</table>";
//als 1 of meer is!
} elseif($count >= 1)
{
while($row = mysql_fetch_array($result))
{
echo "<div align='center'>";
echo "<table width='500' border='0' cellspacing='5'>";;
echo "<tr>";
echo "<td align='left' width='75'> </td>";
echo "<td align='left' width='350' class='sender'>" . $row['sender'] . "</td>";
echo "<td width='75'>#". $row['id'] ."</td>";
echo "</tr>";
echo "<tr>";
echo "<td align='left' width='75'> </td>";
echo "<td align='left' width='350'>" . $row['date'] . "<br>" . $row['time'] . "</td>";
echo "<td width='75'> </td>";
echo "</tr>";
echo "<tr>";
echo "<td align='left' width='75'> </td>";
echo "<td align='left' width='350' class='text'>" . $row['content'] . "<br></td>";
echo "<td width='75'> </td>";
echo "</tr>";
echo "<tr>
<td align='left' width='75'> </td>
<td align='center' width='350'>
<span class='text'>[</span>
<a href='$index?action=delete&id=".$row['id']."'> Delete</a>
<span class='text'>]</span><br><hr color='#222222' width='350px' size='1'></td>
<td width='75'> </td>
<tr>";
echo "</table>";
}
}
//textarea for message
echo "<center>";
echo "<form action='' method='post'>";
echo "<table width='500' border='0' cellspacing='5'>";
echo "<tr>";
echo "<td align='left' width='75'> </td>";
echo "<td align='center' width='350'><textarea name='text' cols='35' rows='5'></textarea>";
echo "<br><input type='submit' name='submit' value='Submit' />";
echo " <input name='reset' type='button' value='Reset' /></td>";
echo "<td width='75'> </td>";
echo "</tr>";
echo "</table>";
echo "</form>";
echo "</div>";
echo "</center>";
//Copyright (footer)
echo "<center>
<div align='center'>$footer<br><br></div>
</div>
</center>";
//Als er op submit is gedrukt.
if(isset($_POST['submit']))
{
mysql_query("INSERT INTO messages (content, sender, date, time) VALUES ('". mysql_real_escape_string ( $_POST['text'] ) . "', 'HIER UW DEFAULT SENDER', NOW(), NOW())");
echo "<meta http-equiv=refresh content=0;URL=".$_SERVER['PHP_SELF'].">";
}
//Delete function
if($_GET['action'] == 'delete') {
if (is_numeric($_GET["id"])) {
$sql = "DELETE FROM messages WHERE id = " . $_GET['id'];
$res = mysql_query($sql);
echo "<meta http-equiv=refresh content=0;URL=$index>";
}
}
?>>[/code]
Reacties
0