install.php formular und funktion in einem

melistik

Erfahrenes Mitglied
Ich möchte gern die Funktion :
PHP:
<?php
$file = $dbconfig;
$config = fileperms ($file);

if ($pw1 != $pw2)
{	echo "<center>pws falsch nicht übereinstimmend!</center>";
	return;
}
else { 	$pw = $pw1;} 
if ($config != 33279)
{	echo "<center>cmod 777 nicht gesetzt !</center>";
	return;
}
$fp = fopen ("$file","w");
	flock ($fp, LOCK_EX) ; // sperren
  	fwrite ($fp, "$banner");  
  	fwrite ($fp, "|--|");
  	fwrite ($fp, "$dbconfig");
  	fwrite ($fp, "|--|");
  	fwrite ($fp, "$pw");
  	fwrite ($fp, "|--|");
  	fwrite ($fp, "$dbposts");
  	fwrite ($fp, "|--|");
	flock ($fp, LOCK_UN);  // öffnen

	echo "<center>Setup ist fertig bitte lösche setup.php und setup.html</center>";

?>
und dieses Forumlar :
PHP:
<html><head>
<meta http-equiv="Content-Language" content="de">
<link href="style.css" rel="stylesheet" type="text/css">
<title>setup</title>
</head><body>
<form method="POST" action="setup.php">
  <div align="center">
    <center>
    <table  id='setupb' cellpadding="1" cellspacing="1">
      <tr><td height="18"><i>
        <font id="setupi">Grundsätzliches Design:</font></i></td>
        <td width="120"></td>
      </tr><tr><td height="1"><font id="setupi">banner</font></td>
        <td width="120"><font id="setupi">
        <input type="text" name="banner" size="20" id="input"></font></td>
        <td height="1"><font id="setupi">Banner Pfad 
        angeben http://...</font></td>
      </tr><tr><td height="18"></td><td width="120"></td>
      </tr><tr><td height="18"><i>
        <font id="setupi">Ordner/Pfade:(prinzipiell so lassen!)</font></i></td>
        <td width="120"></td></tr><tr>
        <td height="18"><font id="setupi">db-config.dat</font></td>
        <td width="120"><font id="setupi">
        <input type="text" name="dbconfig" id="input" size="20" value="db/config.dat"></font></td>
        <td height="18"></td></tr><tr>
        <td height="18"><font id="setupi">db-posts.dat</font></td>
        <td width="120"><font id="setupi">
        <input type="text" name="dbposts" id="input" size="20" value="db/posts.dat"></font></td>
        <td height="18"></td></tr><tr><td height="18"></td>
        <td width="120"></td></tr><tr><td height="1"><i>
        <font id="setupi">Adminbereich:</font></i></td>
        <td width="120"></td></tr><tr>
        <td height="18"><font id="setupi">pw</font></td>
        <td width="120"><front id='setupi'>
        <input type="password" name="pw1" id="input" size="20"></font></td>
        <td height="18"><font id="setupi">Passwort</font></td></tr><tr>
        <td height="18"><font id="setupi">pw</font></td>
        <td width="120"><front id='setupi'>
        <input type="password" name="pw2" id="input" size="20"></td>
        <td height="18"><font id="setupi">Passwort erneut</font></td></tr></table>
    </center></div><p align="center"><input type="submit" value="setup" id="button" name="post"><input type="reset" value="back" id="button" name="back"></p>
</form></body></html>
in einer install.php Datei zusammenfassen. Wie geht soetwas ?
 
Öhm, also erstmal ist in deinem PHP Code überhaupt keine Funktion vorhanden.
Funktionen kennzeichnen sich durch
PHP:
function {
   //Inhalt
}
Ich glaube, das, was du machen willst, ist, die PHP-Datei und die HTML-Datei (das Formular) zusammenzufassen.
Das kann man folgendermaßen bewerkstelligen:
PHP:
<html><head>
<meta http-equiv="Content-Language" content="de">
<link href="style.css" rel="stylesheet" type="text/css">
<title>setup</title>
</head><body>
<?php
if(!$_POST['ok']) { //Wenn das Formular noch nicht abgeschickt wurde, dann wird es angezeigt
   echo '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">
  <div align="center">
    <center>
    <table  id='setupb' cellpadding="1" cellspacing="1">
      <tr><td height="18"><i>
        <font id="setupi">Grundsätzliches Design:</font></i></td>
        <td width="120"></td>
      </tr><tr><td height="1"><font id="setupi">banner</font></td>
        <td width="120"><font id="setupi">
        <input type="text" name="banner" size="20" id="input"></font></td>
        <td height="1"><font id="setupi">Banner Pfad 
        angeben <a href="http://..." target="_blank">http://...</a></font></td>
      </tr><tr><td height="18"></td><td width="120"></td>
      </tr><tr><td height="18"><i>
        <font id="setupi">Ordner/Pfade<img src="images/smilies/frown.gif" border="0" alt="">prinzipiell so lassen!)</font></i></td>
        <td width="120"></td></tr><tr>
        <td height="18"><font id="setupi">db-config.dat</font></td>
        <td width="120"><font id="setupi">
        <input type="text" name="dbconfig" id="input" size="20" value="db/config.dat"></font></td>
        <td height="18"></td></tr><tr>
        <td height="18"><font id="setupi">db-posts.dat</font></td>
        <td width="120"><font id="setupi">
        <input type="text" name="dbposts" id="input" size="20" value="db/posts.dat"></font></td>
        <td height="18"></td></tr><tr><td height="18"></td>
        <td width="120"></td></tr><tr><td height="1"><i>
        <font id="setupi">Adminbereich:</font></i></td>
        <td width="120"></td></tr><tr>
        <td height="18"><font id="setupi">pw</font></td>
        <td width="120"><front id="setupi">
        <input type="password" name="pw1" id="input" size="20"></font></td>
        <td height="18"><font id="setupi">Passwort</font></td></tr><tr>
        <td height="18"><font id="setupi">pw</font></td>
        <td width="120"><front id="setupi">
        <input type="password" name="pw2" id="input" size="20"></td>
        <td height="18"><font id="setupi">Passwort erneut</font></td></tr></table>
    </center></div><p align="center"><input type="submit" value="setup" id="ok" name="ok"><input type="reset" value="back" id="back" name="back"></p>
</form>';
} else {

$file = $dbconfig;
$config = fileperms ($file);

if ($pw1 != $pw2)
{    echo "<center>pws falsch nicht übereinstimmend!</center>";
    return;
}
else {     $pw = $pw1;} 
if ($config != 33279)
{    echo "<center>cmod 777 nicht gesetzt !</center>";
    return;
}
$fp = fopen ("$file","w");
    flock ($fp, LOCK_EX) ; // sperren
      fwrite ($fp, "$banner");  
      fwrite ($fp, "|--|");
      fwrite ($fp, "$dbconfig");
      fwrite ($fp, "|--|");
      fwrite ($fp, "$pw");
      fwrite ($fp, "|--|");
      fwrite ($fp, "$dbposts");
      fwrite ($fp, "|--|");
    flock ($fp, LOCK_UN);  // öffnen

    echo "<center>Setup ist fertig bitte lösche install.php</center>";
}
?>
</body></html>
Das Ganze einfach unter "install.php" abspeichern.
 
Zurück