tutorial-cms-system-v1

Gesponsorde koppelingen

PHP script bestanden

  1. tutorial-cms-system-v1

« Lees de omschrijving en reacties

Add.php
--------------------------------------------------------------

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<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() . "");
                       }
                      }

?>

Admin.php
----------------------------------------------------------------
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
<?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>";
}

?>
  


Dbconnect.php
-------------------------------------------------------------------
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
<?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());?>


Del.php
----------------------------------------------------------------------
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?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.');
  }    
}
  
?>

Edit.php
------------------------------------------------------------------------
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?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>";
  }
}

?>

Show.php
-------------------------------------------------------
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
<?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>";
}

?>
  

Tutorial.php
-----------------------------------------------------------
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?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>
  "
);
}

?>

Sql
-----------------------------------------------------------
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
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;  

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.