Scripts
Tutorial Cms System V1
Hoi iedereen dit is mijn eerste script die ik geschreven heb dus als er fouten zijn pleas corigeer ze uhm bij v2 ga ik dan nog eens proberen ubb codes enz toetevoegen dus mense die willen helpen altijd welkom voor de luie mense :D Download : http://83.149.84.72/~gangstawar/tut.rar Uhm het script is eigenlijk voor webmasters van een tutorial site je kan dus tutorials op je site toevoegen j kan ze dan naaderhand ook verwijderren en bewerken uhm die tutorials houd ook de views bij hoeveel keer het gezien is enz maar de ubb kan ik nog nie dus die zal voor versie 2 zijn
tutorial-cms-system-v1
Add.php
--------------------------------------------------------------
[code] <form method="post">
<p>Title:<br><input type="text" name="frmtitle" size="23" value="Title">
<br />User:<br><input type="text" name="frmauthor" size="23" value="Username">
<br />Email:<br><input type="text" name="frmemail" size="23" value="E@mail">
<br> Description:<br><input type="text" name="frmdescription" size="23" value="">
<br>Message:<br><textarea name="frmcontent" cols="100" rows="25"></textarea>
<br><input type="submit" name="Submit" value="Submit"></p>
</form>
<?php
include("dbconnect.php");
if ($_POST['Submit']) {
$title = $_POST['frmtitle'];
$author = $_POST['frmauthor'];
$description = $_POST['frmdescription'];
$content = $_POST['frmcontent'];
$email = $_POST['frmemail'];
$date = date('m-d-Y');
$sql = "INSERT INTO tutorials SET title='$title',views='0',date='$date',email='$email',content='$content',description='$description',author='$author'";
if (mysql_query($sql)) {
echo("Your tutoral has been added<br /> ");
} else {
echo("Error adding entry: " . mysql_error() . "");
}
}
?> [/code]
Admin.php
----------------------------------------------------------------
[code] <?php
include ("dbconnect.php");
echo "<a href='add.php'>Add a tutorial</a><br>";
$result = mysql_query("SELECT DISTINCT id,title FROM tutorials");
while($row = mysql_fetch_array($result)){
$id = $row['id'];
$title = $row['title'];
echo "-------------------------------------------------------------------<br>";
echo "<a href='del.php?id=$id'>$id</a> $title [<a href='del.php?id=$id'>Delete</a> / <a href='edit.php?id=$id'>Edit</a>]<br>";
}
?> [/code]
Dbconnect.php
-------------------------------------------------------------------
[code] <?php
################################################
#### Made By TreX | pleas dont change stuff ####
#### Info mail [email protected] ####
################www.trex666.net#################
################################################
$hostname = "localhost";
$username = "Username";
$password = "********";
$database = "Dbname";
mysql_connect($hostname,$username,$password) or die("Error connecting to Database!"
. mysql_error()); mysql_select_db($database) or die("Can't select database!" . mysql_error());?> [/code]
Del.php
----------------------------------------------------------------------
[code] <?php
include ("dbconnect.php");
$request_id = $_REQUEST['id'];
$result = mysql_query("SELECT * FROM tutorials WHERE id='$request_id'");
while($row = mysql_fetch_array($result)){
echo "
<form method='post' name='form1'>
Are you sure you want to delete the tutorial: <strong>".$row['title']."<strong>?
<br>
<input name='yes' type='checkbox' id='yes' value='checkbox'>
Yes<br>
<input name='no' type='checkbox' id='no' value='checkbox'>
No
<br>
<input name='submit' type='submit' id='submit' value='Submit'>
</form>";
}
if ($_POST['submit']){
if ($_POST['yes'] && $_POST['no']){
die('Error! : Are you trying to confuse me?');
}
if ($_POST['yes']){
$result = mysql_query("SELECT * FROM tutorials WHERE id='$request_id'");
while($row = mysql_fetch_array($result)){
mysql_query("DELETE FROM tutorials WHERE id='$request_id'");
echo "
Thanks, the tutorial <strong>".$row['title'].".</strong> has been deleted.
<a href='admin.php'>Click here</a> to continue.
";
}
}
if ($_POST['no']){
die('<a href="?">Click here</a> to continue.');
}
if (!$_POST['yes'] && !$_POST['no']){
die('Oops, you forgot to respond to my question.');
}
}
?> [/code]
Edit.php
------------------------------------------------------------------------
[code] <?php
include ("dbconnect.php");
$request_id = $_REQUEST['id'];
$result = mysql_query("SELECT * FROM tutorials WHERE id='$request_id'");
while($row = mysql_fetch_array($result)){
echo "
<form name='form' method='post''>
<table width='80%' border='0' cellspacing='3' cellpadding='0'>
<tr>
<td width='20%'>Name:</td>
<td width='79%'>
<input name='name' type='text' id='name'
] value='".$row['title']."' size='40'></td>
<tr>
<td>Description:</td>
<td>
<input name='description' type='text' id='description'
value='".$row['description']."' size='40'></td>
</tr>
<tr>
<td>Author:</td>
<td><input name='author' type='text' id='author'
value='".$row['author']."' size='40'></td>
</tr>
<tr>
<td>Email:</td>
<td><input name='email' type='text' id='email'
value='".$row['email']."' size='40'></td>
</tr>
<tr>
<td>Content</td>
<td><textarea name='content' cols='65' rows='10'>
".$row['content']."</textarea></td>
</tr>
<tr>
<td><input name='submit' type='submit' id='submit' value='Edit'></td>
<td></td>
</tr>
</table>
</form>
";
if ($_POST['submit']) {
$title = $_POST['frmtitle'];
$author = $_POST['frmauthor'];
$description = $_POST['frmdescription'];
$content = $_POST['frmcontent'];
$email = $_POST['frmemail'];
$date = date('m-d-Y');
mysql_query("UPDATE tutorials SET title='$title',views='0',date='$date',email='$email',content='$content',description='$description',author='$author'") or die('Sorry, it failed');
echo "Success! Your tutorial has been edited.<br>";
}
}
?> [/code]
Show.php
-------------------------------------------------------
[code] <?php
include ("dbconnect.php");
$result = mysql_query("SELECT DISTINCT id,title,description FROM tutorials ");
while($row = mysql_fetch_array($result)){
$id = $row['id'];
$title = $row['title'];
$description = $row['description'];
echo "<a href='tutorial.php?id=$id'>[ID: $id]</a> | [Title: $title] | [Description: $description]<br>";
}
?> [/code]
Tutorial.php
-----------------------------------------------------------
[code] <?php
include ("dbconnect.php");
$request_id = $_REQUEST['id'];
$update = mysql_query("UPDATE tutorials SET views = views + 1 WHERE id='$request_id'");
$result = mysql_query("SELECT * FROM tutorials WHERE id='$request_id'");
while($row = mysql_fetch_array($result)){
$id = $row["id"];
$title = $row["title"];
$date = $row["date"];
$description = $row["description"];
$author = $row["author"];
$email = $row["email"];
$content = $row["content"];
$views = $row["views"];
print (" <table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='400'>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td><table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='275'><div align='left'>Title:<strong> $title </strong></div></td>
<td width='125'><div align='right'> [ Views: $views ]</div></td>
</tr>
</table></td>
</tr>
<tr>
<td><div align='left'>Description: $description </div></td>
</tr>
<tr>
<td><div align='left'>Message: $content </div></td>
</tr>
<tr>
<td><div align='left'>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='150'><div align='left'>Added: $date </div>
</td>
<td><div align='right'>Author:
<a href='mailto:$email'
> $author </a> </div></td>
</tr>
</table>
</div></td>
</tr>
<tr>
</tr>
</table></td>
</tr>
</table>
");
}
?>
[/code]
Sql
-----------------------------------------------------------
[code] CREATE TABLE `tutorials` (
`id` tinyint(11) NOT NULL auto_increment,
`title` text NOT NULL,
`date` varchar(50) NOT NULL,
`description` text NOT NULL,
`author` text NOT NULL,
`email` text NOT NULL,
`content` text NOT NULL,
`views` varchar( 30 ) NOT NULL default '0',
PRIMARY KEY (`ID`)
) TYPE=MyISAM; [/code]
Reacties
0