Results 1 to 5 of 5

Thread: A wild PHP approaches!

  1. #1
    Member Schleicher's Avatar
    Registered
    Jun 2003
    Location
    not in the Playboy Manor =(
    Posts
    3,174

    A wild PHP approaches!

    Ok so i got a html user form. Entered stuff gets stored with $_POST php variables. How do i make the user form write those variables into a .txt document (or somesuch) e.g. i enter something into the form and it gets written into a .txt file.

    Here is the thing. Im using xampp to fart around so its directory is xampp/htdocs/test/ and the file is test.php. The "ouput" file would be something like test.txt

    Its prolly all kinda ugly (formattings on purpose tho) but im just striving for basic understanding here. Bonus points if ya can tell me how to read out of a file and have the data displayed (with an if-echo butttan and form just like below).

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
           "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head><title>test</title></head>
    <font face=verdana><body bgcolor="">
    
    <center><h1><font color=red><b>Zeugs</b></font color=red></h1></center>
    <br><br><br>
    
    <u><b>Hier Zeugs eingeben</b></u> :
    <br><br>
    
    <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
    <Table border=1 bgcolor=yellow>
    <tr>
    <td>Eingabe 1 :</td><td><input type=text maxlength=30 name="eingabe1"></td>
    </tr>
    <td>Auswahl :</td><td><select maxlength=30 name="auswahl">
    	<option>Bitte Auswählen &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </option>
    	<option>2</option>
    	<option>3</option></select></td>
    </table>
    <br><br>
    <input type=submit name="senden" value="Senden">
    </form>
    <br><br>
    
    
    
    <?php
    
    #variablen
    	$senden = $_POST["senden"];
    	$eingabe1 = $_POST["eingabe1"];
    	$auswahl = $_POST["auswahl"];
    #variablen
    
    echo $eingabe1."<br><br>";
    echo $auswahl."<br><br>";
    ?>
    
    <hr style="color:red;background:red;height:15px">
    <br><br>
    
    <center><table border=1 bgcolor=red>
    <tr>
    <td bgcolor=yellow>Eingegeben:</td><td bgcolor=white value="           "> <?php if($senden){echo $eingabe1;}?> </td>
    </tr><tr>
    <td bgcolor=green>Ausgewählt:</td><td> <?php if($senden){echo $auswahl;}?> </td>
    </tr>
    </table></center>
    
    </body>
    </html>
    this took me like one hour s.s

  2. #2

  3. #3
    Member Schleicher's Avatar
    Registered
    Jun 2003
    Location
    not in the Playboy Manor =(
    Posts
    3,174
    Guess i need to google better...

    Ill report my findings once im done digging thru this, thanks

  4. #4
    Member Schleicher's Avatar
    Registered
    Jun 2003
    Location
    not in the Playboy Manor =(
    Posts
    3,174
    Last one did it. Totally unformated but i think if i try to figure how to write to an excel table or somesuch in an organized manner ill just explode.

    More questions later...maybe

  5. #5
    Member Schleicher's Avatar
    Registered
    Jun 2003
    Location
    not in the Playboy Manor =(
    Posts
    3,174
    Something like this was the solution, a simple form saving stuff into an .csv file. Internets is hard :/

    Code:
    <html>
    <head><title>Excel-Datei schreiben</title></head>
    <body>
    <form action="<?php $_SERVER["PHP_SELF"]?>" method="POST">
    
    <input name=datum size=50 type=hidden value="<?php echo date("d.m.y"); ?>">
    <input name=zeit size=50 type=hidden
    value="<?php echo time("dd.mm.yyyy"); ?>">
    
    Nachname: <input name=nachname size=50><br>
    Vorname: <input name=vorname size=50><br>
    eMail:<input name=email size=50><br>
    Newsletter: <input type=checkbox checked name=news size=50><br>
    
    <br><br>
    <input type=submit name"Senden" value ="Abschicken">
    </form>
    
    <?php
    
    #Variablen
    $vname = $_POST["vorname"];
    $nname= $_POST["nachname"];
    $zeit = $_POST["zeit"];
    $datum = $_POST["datum"];
    $email = $_POST["email"];
    $checker = $_POST["news"];
    $sk = ";";
    $ausgabe = $datum.$sk.$zeit.$sk.$vname.$sk.$nname.$sk.$email.$sk.$checker."\n";
    
    
    
    
    # Ausgabe
    #echo $ausgabe;
    
    $fp = fopen("logfile.csv","a");
    fputs($fp, $ausgabe);
    fclose($fp);
    #echo "<P>Das ist der Inhalt der Log-Datei:</P>";
    #readfile("logfile.csv");
    ?>
    
    
    </html>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Komag's Contest 5 approaches
    By Sneaky1Kenobi in forum Community Chat
    Replies: 6
    Last Post: 4th Mar 2004, 12:48 AM
  2. *** RLF DEFEATS NASTY EVIL WILD BILL AND HIS BOYS ***
    By Mad_Gerbil in forum Community Chat
    Replies: 19
    Last Post: 13th Jan 2003, 08:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •