|
|
PHP Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 |
<?php include ("navi.php"); if (isset($_GET['page'])) { $page=$_GET['page'] . ".php"; include ($page); } ?> |
... will heißen es ruft immer mit GET die Dateien board.php subboard.php und post.php auf.

Sorry.|
|
PHP Quellcode |
1 2 3 4 5 6 |
<div> <a href="index.php?page=home">Home</a> <a href="index.php?page=board">Board</a> </div> |
|
|
PHP Quellcode |
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 |
<?php include("configs.php"); $connection=mysql_connect($server,$user,$pass) or die (mysql_error()); mysql_select_db("nedias",$connection) or die (mysql_error()); $sql="SELECT * FROM boards"; $ergebnis=mysql_query($sql,$connection) or die (mysql_error()); print "<?xml version=\"1.0\" ?>"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>nedias free webspace</title> <link rel="stylesheet" href="css/basic.css" type="text/css"> <link rel="stylesheet" href="css/board.css" type="text/css"> </head> <body> <?php echo "<table class='board'>"; echo "<tr><td class='board'>Board</td>"; echo "<td class='threads'>Threads</td>"; echo "<td class='answer'>Antworten</td></tr>"; while($row=mysql_fetch_assoc($ergebnis)) { $id=$row['board']; echo "<tr><td class='board'><a href=\"subboard.php?id=$id\">" . $row['board'] . "</a></td>"; echo "<td class='threads'>" . $row['threads'] . "</td>"; echo "<td class='answer'>" . $row['posts'] . "</td></tr>"; } echo "</table>"; ?> |
|
|
PHP Quellcode |
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 |
<?php include("configs.php"); $currentboard=$_GET['id']; $connection=mysql_connect($server,$user,$pass) or die (mysql_error()); mysql_select_db("nedias",$connection) or die (mysql_error()); $sql="SELECT * FROM threads WHERE in_board='$currentboard'"; $ergebnis=mysql_query($sql,$connection) or die (mysql_error()); print "<?xml version=\"1.0\" ?>"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>nedias free webspace</title> <link rel="stylesheet" href="css/basic.css" type="text/css"> <link rel="stylesheet" href="css/board.css" type="text/css"> </head> <body> <table class="all"><tr><td class="thread">Thread</td><td class="answers">Antworten</td><td class="hits">Hits</td><td class="last_change">Last Change</td></tr> <?php while ($row=mysql_fetch_assoc($ergebnis)) { $id=$row['name']; echo "<tr><td class=\"thread2\"><a href=\"post.php?id=$id\">" . $row['name'] ."</td>"; echo "<td class=\"answers2\">" . $row['answers'] . "</td>"; echo "<td class=\"hits2\">" . $row['hits'] . "</td>"; echo "<td class=\"last_change2\">" . $row['last_change'] . "</td></tr>"; } echo "</table><br/>"; echo "<table class=\"post_bottom\"><tr><td class=\"post_bottom_left\">"; if(session_is_registered('username') || $_SESSION['username'] != "") { echo "<a href=\"newthread.php?id=$currentboard\">Neuen Thread eröffnen</a>"; } else { echo "Sie müssen sich einloggen, um Themen zu eröffnen!"; } echo "</td><td class=\"post_bottom_right\">"; echo "<a href=\"javascript:history.back()\">zurück</a>"; echo "</td></tr></table>"; echo "</body></html>"; mysql_free_result($ergebnis); mysql_close($connection); ?> |
|
|
PHP Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 |
<?php include ("navi.php"); if (isset($_GET['page'])) { $page=$_GET['page']; include ($page); } ?> |
|
|
PHP Quellcode |
1 |
echo "<tr><td class='board'><a href=\"index.php?page=subboard.php?id=$id\">" . $row['board'] . "</a></td>"; |
|
|
PHP Quellcode |
1 2 3 4 5 6 |
<div> <a href="index.php?page=home.php">Home</a> <a href="index.php?page=board.php">Board</a> </div> |
|
|
PHP Quellcode |
1 2 3 4 |
Home Board Warning: include(subboard.php?id=nedias) [function.include]: failed to open stream: Invalid argument in C:\xampp\htdocs\test\index.php on line 8 Warning: include() [function.include]: Failed opening 'subboard.php?id=nedias' for inclusion (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\test\index.php on line 8 |
Habe ich da irgendwas falsch verstanden???
Was ein zusätzliches .php alles bewirken kann...
![]()
PHP Quellcode
1 2 3 4 5 6 7 8 9 10 11 12 <?php include ("navi.php"); if (isset($_GET['page'])) { $page=$_GET['page']; include ($page); } ?>
|
|
PHP Quellcode |
1 2 3 4 |
switch ($_GET['page']) { case 'page1': include('page1.php'); break; case 'page2': include('page2.php'); break; default: include('home.php'); |
|
|
SQL Code |
1 2 3 4 5 6 7 8 9 10 |
# aus diesem hier SELECT * FROM boards # mache lieber SELECT * FROM boards; # ausnutzen kann man dieses, wenn du z.b. dies hast SELECT * FROM posts WHERE threatid = $id # indem man einfach dieses übergibt: threat.php?id=5 JOIN evilstatement #Folge: SELECT * FROM posts WHERE threatid = 5 JOIN evilstatement |
Auch solltest du deine MYSQL Statements am Ende schließen.
![]()
SQL Code
1 2 3 4 5 6 7 8 9 10 # aus diesem hier SELECT * FROM boards # mache lieber SELECT * FROM boards; # ausnutzen kann man dieses, wenn du z.b. dies hast SELECT * FROM posts WHERE threatid = $id # indem man einfach dieses übergibt: threat.php?id=5 JOIN evilstatement #Folge: SELECT * FROM posts WHERE threatid = 5 JOIN evilstatement
Unter http://de.wikipedia.org/wiki/SQL-Injektion#Vorgang findest du einige sehr interessante Beispiele.
Aber das hatten wir schonmal in einem anderen Thread und d0nut hatte dort glaube ich eine gute Lösungsmöglichkeit für PHP5 gepostet.