Php in Html einbinden?

Status
Nicht offen für weitere Antworten.

nullachtneun

Grünschnabel
hallo

ich habe ein problem. ich habe eine website (html) mit 3 frames und möchte als startseite ein php news script einbinden...

mein problem ist... wenn ich auf die page gehe ist der mainFrame weiß aber da soll als startframe dieses newsscript sein... also entweder ich stelle mich zu dumm an ...

wäre nett wenn mir jemand helfen könnte

benutze dreamweaver 8

thx im voraus
 
quellcodes:
topFrame:
PHP:
<style type="text/css">
<!--
body {
	background-image: url(pic/Design/header.jpg);
	background-repeat: no-repeat;
}
-->
</style>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<table width="955" height="174" border="0">
  <tr>
    <td width="631">&nbsp;</td>
    <td width="314"><html>
<head>
<title>MediaPlayer</title>
</head>
<body>


<div align="right">
  <p>&nbsp;  </p>
  <p>
    <script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8','name','theMediaPlayer','width','320','height','144','id','theMediaPlayer','pluginspage','http://www.macromedia.com/go/getflashplayer','bgcolor','#000000','src','mediaplayer','flashvars','file=mp3playlist.xml&width=320&height=100&displaywidth=320&displayheight=0&autostart=true&thumbsinplaylist=true&backcolor=0x000000&frontcolor=0xFFFFFF&lightcolor=0xFF0000','movie','mediaplayer','quality','high','allowfullscreen','false','swliveconnect','true','allowscriptaccess','sameDomain' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8" name="theMediaPlayer"
width="320" height="144"
id="theMediaPlayer">
      <param name=movie value="mediaplayer.swf">
      <param name=quality value="high">
      <param name=bgcolor value="#000000">
      <param name=allowFullScreen value="false">
      <param name=swLiveConnect value="true">
      <param name=allowScriptAccess value="sameDomain">
      <param name="FlashVars" value="file=mp3playlist.xml&width=320&height=100&displaywidth=320&displayheight=0&autostart=true&thumbsinplaylist=true&backcolor=0x000000&frontcolor=0xFFFFFF&lightcolor=0xFF0000">
      <embed type="application/x-shockwave-flash" 
pluginspage="http://www.macromedia.com/go/getflashplayer" 
width="320" height="144" bgcolor="#000000" 
name="theMediaPlayer"
src="mediaplayer.swf"
flashvars="file=mp3playlist.xml&width=320&height=100&displaywidth=320&displayheight=0&autostart=true&thumbsinplaylist=true&backcolor=0x000000&frontcolor=0xFFFFFF&lightcolor=0xFF0000"> </embed>
    </object></noscript>
  </p>
  <p>&nbsp;</p>
</div>
</body>
</html></td>
  </tr>
</table>

leftFrame:
PHP:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Unbenanntes Dokument</title>
<style type="text/css">
<!--
body {
	background-image: url(pic/Design/left.jpg);
	background-repeat: repeat-y;
}
-->
</style>
<script type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}
//-->
</script>
</head>

<body onload="MM_preloadImages('pic/Navigation/news1.jpg','pic/Navigation/events1.jpg','pic/Navigation/crews1.jpg','pic/Navigation/media1.jpg','pic/Navigation/links1.jpg','pic/Navigation/kontakt1.jpg')">
<table border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td><a href="http://www.lyricz-united.de/089/newsposter/news.php" target="mainFrame" onclick="MM_nbGroup('down','group1','News','',1)" onmouseover="MM_nbGroup('over','News','pic/Navigation/news1.jpg','',1)" onmouseout="MM_nbGroup('out')"><img src="pic/Navigation/news.jpg" alt="" name="News" width="180" height="40" border="0" id="News" onload="" /></a></td>
  </tr>
  <tr>
    <td><a href="javascript:;" target="_top" onclick="MM_nbGroup('down','group1','Events','',1)" onmouseover="MM_nbGroup('over','Events','pic/Navigation/events1.jpg','',1)" onmouseout="MM_nbGroup('out')"><img src="pic/Navigation/events.jpg" alt="" name="Events" width="180" height="40" border="0" id="Events" onload="" /></a></td>
  </tr>
  <tr>
    <td><a href="javascript:;" target="_top" onclick="MM_nbGroup('down','group1','Crews','',1)" onmouseover="MM_nbGroup('over','Crews','pic/Navigation/crews1.jpg','',1)" onmouseout="MM_nbGroup('out')"><img src="pic/Navigation/crews.jpg" alt="" name="Crews" width="180" height="40" border="0" id="Crews" onload="" /></a></td>
  </tr>
  <tr>
    <td><a href="javascript:;" target="_top" onclick="MM_nbGroup('down','group1','Media','',1)" onmouseover="MM_nbGroup('over','Media','pic/Navigation/media1.jpg','',1)" onmouseout="MM_nbGroup('out')"><img src="pic/Navigation/media.jpg" alt="" name="Media" width="180" height="40" border="0" id="Media" onload="" /></a></td>
  </tr>
  <tr>
    <td><a href="javascript:;" target="_top" onclick="MM_nbGroup('down','group1','Links','',1)" onmouseover="MM_nbGroup('over','Links','pic/Navigation/links1.jpg','',1)" onmouseout="MM_nbGroup('out')"><img src="pic/Navigation/links.jpg" alt="" name="Links" width="180" height="40" border="0" id="Links" onload="" /></a></td>
  </tr>
  <tr>
    <td><a href="javascript:;" target="_top" onclick="MM_nbGroup('down','group1','Kontakt','',1)" onmouseover="MM_nbGroup('over','Kontakt','pic/Navigation/kontakt1.jpg','',1)" onmouseout="MM_nbGroup('out')"><img src="pic/Navigation/kontakt.jpg" alt="" name="Kontakt" width="180" height="40" border="0" id="Kontakt" onload="" /></a></td>
  </tr>
</table>
<br />
</body>
</html>
php news script:

PHP:
<?

if(!isset($posten)) {
$posten = ""; }

if($posten == "kom") {
echo "<font face=\"Arial\" size=\"3\"><b>Kommentare</b></font><br><br>";

$dubist1 = $datname;

if(file_exists("news/$dubist1.txt")) {
$news = file("news/$dubist1.txt");

$body = "";
for($z = 1; $z <= count($news); $z++) {

$dat = explode("|", $news[count($news) - $z]);

$body1 = implode("", file("layout/bodykom.htm"));

$body1 = str_replace("<-datum->", $dat[0], $body1);
$body1 = str_replace("<-titel->", $dat[1], $body1);
$body1 = str_replace("<-text->", $dat[2], $body1);
if($dat[4] == "kom" and $dat[3] == "$post") {
$body = "$body$body1"; }
$body = stripslashes ($body);
}
}
else { $body = "<font face=\"Arial\"><small>Sorry ... kann keine News zu diesem Thema finden</small></font><br><br>"; }

$down = implode("", file("layout/down.htm"));
$down = stripslashes ($down);

echo "$body";
echo "<font face=\"Arial\"><small><a href=\"$PHP_SELF?posten=&thema=$thema&datname=$datname\">Zurück</a></small></font>";
echo "<hr><br>";
echo "<font face=\"Arial\" color=\"#1084C8\"><small><b>Kommentar  schreiben</b></small></font><br><br><br>";

echo "<form action=\"$PHP_SELF\" method=\"Post\">";
echo "<table width=\"100%\">";
echo "<tr>";
echo "<td><font face=\"Arial\"><small>Titel </small></font></td><td><input type=\"Text\" name=\"titel\" value=\"\" size=\"50\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td><font face=\"Arial\"><small>Text </small></font></td><td><textarea name=\"text\" cols=\"45\" rows=\"5\"></textarea></td>";
echo "</tr>";
echo "</table>";
echo "<input type=\"hidden\" name=\"post\" value=\"$post\">";
echo "<input type=\"hidden\" name=\"thema\" value=\"$thema\">";
echo "<input type=\"hidden\" name=\"datname\" value=\"$datname\">";
echo "<input type=\"hidden\" name=\"posten\" value=\"Kommentar Speichern\">";
echo "<br>";
echo "<input type=\"Submit\" name=\"posten\" value=\"Kommentar Speichern\">";
echo "</form>";
echo "</body></html>";


}

if($posten == "ein") {
echo "<html><head><title>News Poster</title></head><body bgcolor=\"#FFFFFF\">";
echo "<font face=\"Arial\" color=\"#1084C8\"><small><b>News zu Thema $thema schreiben</b></small></font><br><br><br>";
echo "<form action=\"$PHP_SELF\" method=\"Post\">";
echo "<table width=\"100%\">";
echo "<tr>";
echo "<td><font face=\"Arial\"><small>Titel </small></font></td><td><input type=\"Text\" name=\"titel\" value=\"\" size=\"50\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td><font face=\"Arial\"><small>Text </small></font></td><td><textarea name=\"text\" cols=\"45\" rows=\"5\"></textarea></td>";
echo "</tr>";
echo "<tr>";
echo "<td><font face=\"Arial\"><small>Passwort </small></font></td><td><input type=\"password\" name=\"pass\" value=\"\" size=\"10\"></td>";
echo "</tr>";
echo "</table>";
echo "<input type=\"hidden\" name=\"thema\" value=\"$thema\">";
echo "<input type=\"hidden\" name=\"datname\" value=\"$datname\">";
echo "<input type=\"hidden\" name=\"posten\" value=\"Speichern\">";
echo "<br>";
echo "<input type=\"Submit\" name=\"posten\" value=\"Speichern\">";
echo "</form>";
echo "</body></html>";
exit;
}
if($posten == "Speichern") {


$data = "dat.php";

require $data;

if($pass != $passwort) {
echo "Sie haben kein Recht News zu Posten";
exit;
}

 $datum = date("d.m.Y");
 $date = getdate();

if(file_exists("news/$datname.txt")) {
$newline = "\n";
}
else {
$newline = ""; }

$text = preg_replace("/\r\n|\r|\n/", "<br>", $text);
$count1 = $count + 1;
$datei = fopen("news/$datname.txt", "a+");
fputs($datei, "$newline$datum|$titel|$text|$count1||");
$fertig = fclose($datei);

$datei = fopen("dat.php", "w+");
fputs($datei, "<?\n\$passwort=\"$passwort\";\n\$count=\"$count1\";\n?>");
$fertig = fclose($datei);

echo "<html><head><title>News Poster</title></head><body bgcolor=\"#FFFFFF\">";
echo "<font face=\"Arial\"><small>Die Daten wurden gespeichert - <a href=\"$PHP_SELF?dubist=$thema\">Das will ich sehen!</a></small></font>";
echo "</body></html>";
exit;
}
if($posten == "Kommentar Speichern") {

$data = "dat.php";

require $data;

 $datum = date("d.m.Y");
 $date = getdate();

if(file_exists("news/$datname.txt")) {
$newline = "\n";
}
else {
$newline = ""; }

$text = preg_replace("/\r\n|\r|\n/", "<br>", $text);

$spamcheck = file("news/$datname.txt");

$i = "0";

while($i < count($spamcheck)) {

$dat = explode("|", $spamcheck[$i]);

if($dat[3] == $post and $dat[4] == "kom") {
$lasttext = $dat[2]; }

$i++;
}

if($text != $lasttext) {
$datei = fopen("news/$datname.txt", "a+");
fputs($datei, "$newline$datum|$titel|$text|$post|kom|");
$fertig = fclose($datei);

echo "<html><head><title>News Poster</title></head><body bgcolor=\"#FFFFFF\">";
echo "<font face=\"Arial\"><small>Der Kommentar wurd gespeichert - <a href=\"$PHP_SELF?thema=$thema&datname=$datname&posten=kom&post=$post\">Das will ich sehen!</a></small></font>";
echo "</body></html>";
exit;}
else {
  echo "<center><b><font face=\"Arial\" color=\"#FF0000\"><small>Spam-Schutz!</small></font></b></center>";
  echo "<center><font face=\"Arial\"><small>Um Spam Einträg zu verhindern, wird ihr Beitrag nicht Eingetragen.<br><br><a href=\"$PHP_SELF?thema=$thema&datname=$datname&posten=kom&post=$post\">Zur&uuml;ck</a></small></font></center>";
}
}

if($posten == "cutdo") {
$data = "dat.php";

require $data;

if($pass != $passwort) {
echo "<font face=\"Arial\" size=\"2\">Ihr Passwort ist nicht Korrekt!</font>";
}
else {
$data = "";
if (file_exists("news/$thema.txt"))
{
                   $afile = file("news/$thema.txt");
                   for($num = 0; $num < count($afile); $num++)
                   {
                                   // Datei trennen
                            $bfile = explode("|",$afile[$num]);

                           if($bfile[3] == $post) {
                                $afile[$num] = "";}

                         $data ="$data$afile[$num]";
                        }

                $file = fopen("news/$thema.txt","w+");
                fputs($file, "$data");
                fclose($file);}
echo "<font face=\"Arial\" size=\"2\">Meldung gel&ouml;scht.</font><br><br>";
          }
echo "<font face=\"Arial\" size=\"2\"><a href=\"news.php\">Zur&uuml;ck</a></font>";
}

if($posten == "cut") {
echo "<html><head><title>News Poster</title></head><body bgcolor=\"#FFFFFF\">";
echo "<font face=\"Arial\" color=\"#1084C8\"><small><b>Sind Sie sich sicher das Sie diese Meldung löschen wollen?</b></small></font><br><br><br>";
echo "<form action=\"$PHP_SELF\" method=\"Post\">";
echo "<table width=\"100%\">";
echo "<tr>";
echo "<td><font face=\"Arial\"><small>Passwort </small></font></td><td><input type=\"password\" name=\"pass\" value=\"\" size=\"30\"></td>";
echo "</tr>";
echo "</table>";
echo "<input type=\"hidden\" name=\"thema\" value=\"$thema\">";
echo "<input type=\"hidden\" name=\"post\" value=\"$post\">";
echo "<input type=\"hidden\" name=\"posten\" value=\"cutdo\">";
echo "<br>";
echo "<input type=\"Submit\" name=\"but\" value=\"Ja, weg damit!\">";
echo "</form>";
echo "</body></html>";
}

if($posten == "") {
$newskat = file("newskat.txt");
$katlist = "";

for($z = 0; $z < count($newskat); $z++) {

$dat = explode("|", $newskat[$z]);

if(!isset($dubist)) {
$dubist = $dat[0];
}

if($katlist != "") {
$katlist = "$katlist | ";
}

if($dat[0] == $dubist) {
$katlist = "$katlist$dubist";
$dubist1 = $dat[1];
}
if($dat[0] != $dubist) {
$katlist = "$katlist"."<a href=\"$PHP_SELF?dubist=$dat[0]\">$dat[0]</a>";
}
}

$kopflay = implode("", file("layout/kopf.htm"));
$kopflay = str_replace("<-kat->", $katlist, $kopflay);
$kopflay = stripslashes ($kopflay);

if(file_exists("news/$dubist1.txt")) {
$news = file("news/$dubist1.txt");

$body = "";
for($z = 1; $z <= count($news); $z++) {

$dat = explode("|", $news[count($news) - $z]);

$komz = "0";
for($a = 1; $a <= count($news); $a++) {

$at = explode("|", $news[count($news) - $a]);

if($dat[3] == $at[3] and $at[4] == "kom") {
$komz++;
}

}

$body1 = implode("", file("layout/body.htm"));

$body1 = str_replace("<-datum->", $dat[0], $body1);
$body1 = str_replace("<-titel->", $dat[1], $body1);
$body1 = str_replace("<-text->", $dat[2], $body1);
$body1 = str_replace("<-cutpost->", "<a href=\"$PHP_SELF?posten=cut&thema=$dubist&datname=$dubist1&post=$dat[3]\">Post Löschen</a>", $body1);
$body1 = str_replace("<-showkom->", "<a href=\"$PHP_SELF?posten=kom&thema=$dubist&datname=$dubist1&post=$dat[3]\">Kommentare ($komz)</a>", $body1);
if($dat[4] != "kom") {
$body = "$body$body1"; }
$body = stripslashes ($body);
}
}
else { $body = "<font face=\"Arial\"><small>Sorry ... kann keine News zu diesem Thema finden</small></font><br><br>"; }

$down = implode("", file("layout/down.htm"));
$down = stripslashes ($down);

echo "$kopflay";
echo "$body";
echo "<font face=\"Arial\"><small><small><div align=\"right\"><a href=$PHP_SELF?posten=ein&thema=$dubist&datname=$dubist1>News Posten</a></div></small></small></font><br>";
echo "$down";}
echo "</body></html>";
?>

sry bin blutiger anfänger aber news müssen sein...
 
Soweit ich weiss geht PHP in HTML selbst nicht da müsstest du deine Datei endung auf php umschreiben

Den meines erachtens funktioniert nur HTML in PHP aber anderst herum nicht

Das heisst du machst aus .html einfach .php draus
 
Hallo

Lenox hat recht. Das PHP Programm auf dem Server ignoriert Files, die nicht mit .php enden. Einfach umbenennen, dann sollte alles en.

Gruss

FG
 
Ich denke mal mit der endung phtml geht es auch oder irre ich mich da? wenn ich mich irre bitte diesen post löschen, danke

MfG
KD3
 
Also von PHTML habe ich bisher noch nichts gehört, aber das ist doch gar nicht so schwer. Nenne deine datei.html einfach in datei.php um. PHP Dateien erkennen HTML ohne Probleme. Aber umgekehrt ist das nicht möglich. Und PHTML wäre was neues, das gibt es meines Wissens nicht, wäre ja auch unnötig weil man das ja genauso in einer PHP Datei machen könnte
 
Das hängt ganz von der Serverkonfiguration ab, jenachdem was da eingestellt ist, werden von mir aus auch Dateien mit der Endung *.butterbrot von PHP verarbeitet.:)

*.phtml wird es beim Apache idR. standardmässig, genauso wie noch .php3 .php4 .php5
 
Status
Nicht offen für weitere Antworten.
Zurück