Jeg har nogen problemmer med mit Nyhedsscript
Hej jeg har nogen problemmer med mit script Den siger det her+ os jeg kan heller ikke loggin på så siger den bare forkert pass eller brugernavn
http://www.flelx.1go.dk/3_0.8/index.php
Ligger lige alle filnerne ud.. Det er et downloade script
index.php....................................
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<h1>Nyeste nyheder</h1>
<?php
include_once('inc.config.php');
mysql_connect($cfg['mysql']['host'],$cfg['mysql']['username'],$cfg['mysql']['password']);
mysql_select_db($cfg['mysql']['database']);
$query = mysql_query("SELECT id,title,image,synopsis FROM news ORDER BY id DESC LIMIT 5") or die(mysql_error());
while ($row = mysql_fetch_assoc($query)) {
if ($i++ != 0) echo '<div class="hr"></div>';
echo '<h2><a href="news.display.php?id='.$row['id'].'">'.$row['title'].'</a></h2>';
echo empty($row['image']) ? '' : '<img src="files/'.$row['image'].'" class="image">';
echo $row['synopsis'];
}
?>
<div class="hr"></div>
<a href="http://schaefner.dk" class="author">schaefner|dk</a> <a href="news.search.php">Søg efter nyhed</a> | <a href="admin/">Administration</a>
</body>
</html>
inc.config.php.........................................
<?php
$sql_host = "HOST"; //dit host
$sql_user = "BRUGERNAVN"; //dir brugernavn
$sql_passwd = "KODEORD";//din kode
$db = "DATABASENAVN"; //din database
mysql_connect($sql_host,$sql_user,$sql_passwd)or die (mysql_error());
mysql_select_db($db)or die (mysql_error());
$cfg['admin']['test'] = 'abc'; // Brugernavn til administrationsmodul
$cfg['admin']['test'] = 'abc'; // Kodeord til administrationsmodul
/* Indstillinger : side */
$cfg['limit'] = 10; // Antal resultater pr. side.
$cfg['pages_each_way'] = 7; // Sider der peger hver vej
?>
Form.handle.php......................................
<?php
include('inc.config.php');
mysql_connect($cfg['mysql']['host'],$cfg['mysql']['username'],$cfg['mysql']['password']);
mysql_select_db($cfg['mysql']['database']);
if ($_POST['referer'] == 'comment') {
if (empty($_POST['name']) && empty($_POST['text'])) {
echo '<font color="red">Alle felter er ikke udfyldt!</font>';
} else {
$_POST['email'] = preg_match("/^[\w\.\-_]+@([\w\-_]+\.)+\w+$/i",$_POST['email']) ? $_POST['email'] : '';
mysql_query("INSERT INTO comments VALUES ('','".$_POST['name']."','".$_POST['email']."',now(),'".$_POST['text']."','".$_POST['parent']."')") or die(mysql_error());
header("Location: news.display.php?id=".$_POST['parent']);
}
}
?>
news.display.php.............................................
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<?php
include_once('inc.config.php');
mysql_connect($cfg['mysql']['host'],$cfg['mysql']['username'],$cfg['mysql']['password']);
mysql_select_db($cfg['mysql']['database']);
$query = mysql_query("SELECT *,DATE_FORMAT(date,'%e/%c-%y %T') AS date FROM news WHERE id=".$_GET['id']."");
$row = mysql_fetch_assoc($query);
echo '<h1>'.$row['title'].'</h1>';
echo '<p><b>'.$row['synopsis'].'</b></p>';
echo '<p>'.$row['author'].' - '.$row['date'].'</p>';
echo nl2br($row['text']);
echo '<div class="hr"></div>';
$query = mysql_query("SELECT *,DATE_FORMAT(date,'%e/%c-%y %T') AS date FROM comments WHERE parent=".$_GET['id']." ORDER BY id ASC");
if (mysql_num_rows($query) > 0) {
echo '<h2>Kommentarer</h2>';
while ($row = mysql_fetch_assoc($query)) {
echo empty($row['email']) ? htmlspecialchars($row['name']) : '<a href="mailto:'.$row['email'].'">'.htmlspecialchars($row['name']).'</a>';
echo ' ('.$row['date'].')<br><br>';
echo nl2br(htmlspecialchars($row['text']));
echo '<div class="hr"></div>';
}
}
?>
<h2>Kommenter nyhed</h2>
<form method="post" action="form.handle.php">
<input type="hidden" name="referer" value="comment">
<input type="hidden" name="parent" value="<?php echo $_GET['id']; ?>">
Navn: <input type="text" name="name" style="width: 120px">
Email: <input type="text" name="email" style="width: 120px"><br>
<textarea name="text" rows="7" cols="0" style="width: 328px"></textarea><br><br>
<input type="submit" value="Send">
</form>
<div class="hr"></div>
<a href="http://schaefner.dk" class="author">schaefner|dk</a> <a href="index.php">Nyeste</a> | <a href="news.search.php">Søg efter nyhed</a> | <a href="admin/">Administration</a>
</body>
</html>
news.search.php..............................................
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<h1>Søg efter nyhed</h1>
Der søges i overskrift og tekst i de oprettede nyheder. Hvis du ikke indtaster et søgeord vil alle resultater blive vist!<br><br>
<form action="news.search.php">
<table><tr>
<td>Søgeord:<br><input type="text" name="q"> </td>
<td>Sorter efter:<br><select name="sort"><option value="title">Overskrift</option><option value="author">Forfatter</option><option value="id">Dato</option></select> </td>
<td>Sortering:<br><select name="order"><option value="desc">Faldende [z-a]</option><option value="asc">Stigende [a-z]</option></select></td>
</tr></table>
<input type="submit" value="Udfør">
</form>
<?php
if (isset($_GET['q'])) {
include_once('inc.config.php');
mysql_connect($cfg['mysql']['host'],$cfg['mysql']['username'],$cfg['mysql']['password']);
mysql_select_db($cfg['mysql']['database']);
echo '<hr>';
echo '<h2>Resultater af din søgning på: "'.$_GET['q'].'"</h2>';
$offset = isset($_GET['offset']) ? $_GET['offset'] : 0;
$query = mysql_query("SELECT id,title,author,DATE_FORMAT(date,'%e/%c-%y %T') AS date FROM news WHERE title LIKE '%".$_GET['q']."%' OR text LIKE '%".$_GET['q']."%' ORDER BY ".$_GET['sort']." ".$_GET['order']." LIMIT ".$offset.",".$cfg['limit']."") or die(mysql_error());
if (mysql_num_rows($query) == 0){
echo 'Ingen resultater af din søgning!<br />';
} else {
echo '<table id="list"><tr>';
echo '<th width="50%">Overskrift</th><th width="50%">Forfatter</th><th nowrap>Dato</th>';
echo '</tr>';
while ($row = mysql_fetch_assoc($query)) {
echo '<tr>';
echo '<td width="50%"><a href="news.display.php?id='.$row['id'].'">'.$row['title'].'</a></td>';
echo '<td width="550%">'.$row['author'].'</td>';
echo '<td nowrap>'.$row['date'].'</td>';
echo '</tr>';
}
echo '</table>';
echo '<br>';
$total = mysql_result(mysql_query("SELECT id,title,author,DATE_FORMAT(date,'%e/%c-%y %T') AS date FROM news WHERE title LIKE '%".$_GET['q']."%' OR text LIKE '%".$_GET['q']."%'"),0);
$start_point = ($offset-($cfg['pages_each_way']*$cfg['limit']) < 0) ? 0 : $offset-($cfg['pages_each_way']*$cfg['limit']);
$end_point = ($offset+($cfg['pages_each_way']*$cfg['limit']) > $total) ? $total : $offset+($cfg['pages_each_way']*$cfg['limit']);
$page_number = ($start_point/$cfg['limit'])+1;
echo ($offset >= $cfg['limit']) ? '<a href="?offset='.($offset-$cfg['limit']).'&q='.$_GET['q'].'&sort='.$_GET['sort'].'&order='.$_GET['order'].'">Forrige</a> ' : 'Forrige ';
for ($start=$start_point;$start<$end_point;$start=$start+$cfg['limit']) {
echo ($offset == $start) ? '<b>'.$page_number++.'</b> ' : '<a href="?offset='.$start.'&q='.$_GET['q'].'&sort='.$_GET['sort'].'&order='.$_GET['order'].'">'.$page_number++.'</a> ';
}
echo ($total > $offset+$cfg['limit']) ? '<a href="?offset='.($offset+$cfg['limit']).'&q='.$_GET['q'].'&sort='.$_GET['sort'].'&order='.$_GET['order'].'">Næste</a>' : 'Næste';
}
}
?>
<div class="hr"></div>
<a href="http://schaefner.dk" class="author">schaefner|dk</a> <a href="index.php">Nyeste</a> | <a href="admin/">Administration</a>
</body>
</html>