berni: Wie halte ich Daten, die aus einem form kommen in einer PHP???

hi@all!

ich hab da ein problem, das folgendermaßen aussieht:

ich hab eine connect.php, die soll mit der mysql-db verbinden. da diese datei aber ein teil eines cms ist, wird das cms downgeloadet, sollen die daten der datenbankanbindung über ein setup-form in die connect.php reingeschrieben werden, aber leider hält die connect.php, die eingegebenen daten nicht!

die connect.php schaut derzeit so aus:

<?
if(isset($_POST['submit']))
{
  $db_user = $_POST['user'];
  $db_pass = $_POST['pass'];
  $db_host = $_POST['host'];
  $db_name = $_POST['dbname'];

$db_user = "$user";
  $db_pass = "$pass";
  $db_host = "$host";
  $db_name = "$dbname";
$con= @mysql_connect($db_host,$db_user,$db_pass)
or die ("Cannot connect to MySQL.");
$db = @mysql_select_db($db_name,$con)
or die ("Cannot select the $db_name database. Please check your details in the database connection file and try again");
print "Datenbankverbindung erfolgreich!";
}else{}

?>

das form, wo die variablen eingesetzt werden, schaut so aus:

<input type="submit" value="db-connect" name="submit" ...
<input type="text" name="user" size="18" style="color: #FFFFFF; font-family: Verdana; font-size: 8pt; border: 1px solid #FFFF00; background-color: #314470</font></p>
<p style="margin-left: 6; margin-right: 6" align="center">
<font size="1">Passwort:
<input type="password" name="pass" size="18" style="color: #FFFFFF; font-family: Verdana; font-size: 8pt; border: 1px solid #FFFF00; background-color: #314477</font></p>
<p style="margin-left: 6; margin-right: 6" align="center">
<font size="1">Datenbankname:
<input type="text" name="dbname" size="18" style="color: #FFFFFF; font-family: Verdana; font-size: 8pt; border: 1px solid #FFFF00; background-color: #314477</font></p>
<p style="margin-left: 6; margin-right: 6" align="center">
<font size="1">HostName:
<input type="text" name="host" size="18" style="color: #FFFFFF; font-family: Verdana; font-size: 8pt; border: 1px solid #FFFF00; padding-left: 4; padding-right: 4; padding-top: 1; padding-bottom: 1; background-color: #314477"> (meist 'localhost') </font></p>
<p style="margin-left: 6; margin-right: 6" align="center">
<input type="submit" value="db-connect" name="B1" style="color: #FFFF00; font-family: Verdana; font-size: 8pt; border: 1px ridge #FFFF00; background-color: #314477">

es klappt zwar die datenbankverbindung - wie oben im connect.php im 'print' geschrieben, a b e r  diese daten sind weg in der connect.php (die übrigens vollen schreibzugriff hat), wenn ich tabellen in der db anlegen will.

BITTE was mach ich da falsch, dass die daten in der connect.php bleiben, die ich mit dem <form... eintrug???

  1. Moin!

    ich hab eine connect.php, die soll mit der mysql-db verbinden. da diese datei aber ein teil eines cms ist, wird das cms downgeloadet, sollen die daten der datenbankanbindung über ein setup-form in die connect.php reingeschrieben werden, aber leider hält die connect.php, die eingegebenen daten nicht!

    Was heißt hier "hält"? "BE_hält"? Oder "ER_hält"?

    Bei "ER_hält" würde ich dich fragen, welche PHP-Version du einsetzt und ob der Befehl "phpinfo(INFOVARIABLES);", wenn du ihn an den Anfang deiner connect.php setzt, irgendwo die gewünschten Informationen aus dem Formular wiedergibt.

    Bei "BE_hält" würde ich dich fragen, warum du nirgendwo die Konfigurationsdaten dauerhaft abspeicherst. Variablenwerte gehen nach Beenden des Skriptes nämlich verloren. Deswegen hat man ja solche schlauen Einrichtungen wie Datenbanken und Dateien erfunden, damit man etwas dauerhaft speichern und später wieder darauf zugreifen kann. Zu deiner Freunde darf ich dir mitteilen: PHP-Skripte sind auch nur ganz normale Textdateien - man kann sie mit PHP erzeugen und als PHP-Code mittels include() einbinden.

    - Sven Rautenberg

    --
    Die SelfHTML-Developer sagen Dankeschön für aktuell 21205,05 Euro Spendengelder!
    1. Was heißt hier "hält"? "BE_hält"? Oder "ER_hält"?

      Bei "ER_hält" würde ich dich fragen, welche PHP-Version du einsetzt und ob der Befehl "phpinfo(INFOVARIABLES);", wenn du ihn an den Anfang deiner connect.php setzt, irgendwo die gewünschten Informationen aus dem Formular wiedergibt.

      Bei "BE_hält" würde ich dich fragen, warum du nirgendwo die Konfigurationsdaten dauerhaft abspeicherst. Variablenwerte gehen nach Beenden des Skriptes nämlich verloren. Deswegen hat man ja solche schlauen Einrichtungen wie Datenbanken und Dateien erfunden, damit man etwas dauerhaft speichern und später wieder darauf zugreifen kann. Zu deiner Freunde darf ich dir mitteilen: PHP-Skripte sind auch nur ganz normale Textdateien - man kann sie mit PHP erzeugen und als PHP-Code mittels include() einbinden.

      - Sven Rautenberg

      ...sorry sven, what is the message of your hints?? i did'nt find any code, but ....

      berni

      1. Moin!

        Was heißt hier "hält"? "BE_hält"? Oder "ER_hält"?

        Bei "ER_hält" würde ich dich fragen, welche PHP-Version du einsetzt und ob der Befehl "phpinfo(INFOVARIABLES);", wenn du ihn an den Anfang deiner connect.php setzt, irgendwo die gewünschten Informationen aus dem Formular wiedergibt.

        Bei "BE_hält" würde ich dich fragen, warum du nirgendwo die Konfigurationsdaten dauerhaft abspeicherst. Variablenwerte gehen nach Beenden des Skriptes nämlich verloren. Deswegen hat man ja solche schlauen Einrichtungen wie Datenbanken und Dateien erfunden, damit man etwas dauerhaft speichern und später wieder darauf zugreifen kann. Zu deiner Freunde darf ich dir mitteilen: PHP-Skripte sind auch nur ganz normale Textdateien - man kann sie mit PHP erzeugen und als PHP-Code mittels include() einbinden.

        - Sven Rautenberg

        ...sorry sven, what is the message of your hints?? i did'nt find any code, but ....

        "Use the force, Luke!"

        Doesn't your PHP script receive the data, or doesn't it remember them?

        If it does not receive them, use "ER_hält".

        If it does not remember them, use "BE_hält".

        Was willst du jetzt eigentlich wissen?
        (Translation: What ist is exactly that you want to know?)

        - Sven Rautenberg

        --
        Die SelfHTML-Developer sagen Dankeschön für aktuell 21205,05 Euro Spendengelder!
        1. Moin!
          "Use the force, Luke!"

          Doesn't your PHP script receive the data, or doesn't it remember them?

          If it does not receive them, use "ER_hält".

          If it does not remember them, use "BE_hält".

          <img src="/images/03.gif" border="0" alt="">
          (Translation: What ist is exactly that you want to know?)

          - Sven Rautenberg

          hi!

          just call me yoda ;-). i used it, force i meant.

          this bullshit-file (connect.php) does not  s t o r e  the data i put in with the html-form.

          i understood your hint called "BE-hält", but i could'nt make a code, creating four files *.txt to store the mysql-db data.

          but i suppose, this woud'nt be the only problem.

          the commmand 'include()' is a problem too, because the main-data (i called it connect.php, ist not able to read the content of the 4 *.txt (password, user, hostname, databasename). with the command include() or reqire() comes a parse-error (i don't know exactly what it says, but friend of mine told me, i have to use fread()... instead of include(). but fread did also not work :-(((. So i expect you to support me, by giving some good (working) codes! :-)

          so long
          force will be with you
          berni

          1. Moin!

            this bullshit-file (connect.php) does not  s t o r e  the data i put in with the html-form.

            Because you did not program any code which stores the data.

            i understood your hint called "BE-hält", but i could'nt make a code, creating four files *.txt to store the mysql-db data.

            Not? Too bad. You are using a database, which is considered a more sophisticated way of storing data, which, basically, is supposed only to be done after enough knowledge about file access methodes is aquired.

            Go for it! Aquire more knowledge about using files as a data storing method. The PHP manual provides you with a vast array of examples, user contributions and function descriptions. I recommend you start right here: http://www.php.net/fopen

            Remember: You have to implement PHP code which generates a text file, which contains valid PHP code, which defines variables containing the submitted form values.

            You can then include this textfile within any script and after inclusion use the defined variables in your connection function.

            the commmand 'include()' is a problem too, because the main-data (i called it connect.php, ist not able to read the content of the 4 *.txt (password, user, hostname, databasename).

            You don't have "4 *.txt". The only thing you have is volatile data stored in 4 variables. Those are deleted after the script has finished. You either store them somewhere (using the database would be a silly idea, as you'd have no method to access them again), or lose them.

            So i expect you to support me, by giving some good (working) codes! :-)

            So you "expect me to" do things? How unpolite of you!

            You may "kindly ask" me if I "might be able to" help you by providing some help - as I did. Everything else is beyond your means.

            - Sven Rautenberg

            --
            Die SelfHTML-Developer sagen Dankeschön für aktuell 21205,05 Euro Spendengelder!
          2. Hallo!

            <intelligentshitting>

            instead of include(). but fread <del>did also not<del> <ins>didn't either</ins> work :-(((. So i expect you to support me, by giving some good (working) codes! :-)

            </intelligentshitting>

            Gruß

            mdkiller

            1. Moin!

              <betterknower>

              <intelligentshitting>

              but fread <del>did also not<del> <ins>didn't <del>either</del></ins> work <ins>, either</ins> :-(((.
              </intelligentshitting>

              </betterknower>

              - Sven Rautenberg

              --
              Die SelfHTML-Developer sagen Dankeschön für aktuell 21205,05 Euro Spendengelder!