Results 1 to 3 of 3

Thread: PHP multiple forms submission

  1. #1
    hakermania's Avatar
    hakermania is offline Τώρα ξέρεις τι γράφω εδώ!
    Join Date
    Aug 2009
    Location
    Greece
    Beans
    1,704
    Distro
    Ubuntu Development Release

    Question PHP multiple forms submission

    I've created this code in PHP and I'm a complete newbie (i've done something in the past regarding email-sending but nothing more...)
    So, as I put this code inside my .php file and request it to load, an empty page is presented. What is the actual problem to the code?
    Thx in advance for any answer!
    Code:
    <?php
    $wfilename = $_POST["wfilename"];
    $wbody = $_POST["wbody"];
    $rfilename = $_POST["rfilename"];
    ?>
    <html>
    <head>
    <title>Write/Read files!</title>
    </head>
    <body>
    <h1>WRITE FILES</h1>
    <form method="post" action="<?php echo $PHP_SELF;?>">
    Write filename:<input type="text" size="30" maxlength="30" name="wfilename">:<br />
    Body:<br /><textarea rows="20" cols="20" name="wbody" wrap="physical"></textarea><br /> 
    <input type="submit" value="write" name="write"><br />
    </form><br /> 
    
    <br />
    <h1>READ FILES</h1>
    <form method="post" action="<?php echo $PHP_SELF;?>">
    Write filename:<input type="text" size="30" maxlength="30" name="rfilename"><br />
    <input type="submit" value="read" name="read"><br />
    </form><br /> 
    
    
    <?php
    if ($_POST['read'])
    {
    $fh = fopen($rfilename, 'r') or die(":(");
    $theData = fread($fh, 5);
    fclose($fh);
    echo "$rfilename contains:\n\n$theData";
    }
    else if ($_POST['write']) {
    $fh = fopen($wfilename, 'w') or die("can't open file");
    fwrite($fh, $wbody);
    fclose($fh);
    echo "$wbody was successfully written to $wfilename"
    }
    Website

    Wallch (Wallpaper Changer): Sourceforge | Launchpad

  2. #2
    Join Date
    Jan 2011
    Location
    New Zealand
    Beans
    10
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: PHP multiple forms submission

    Check to make sure all of your tags are closed (including body) by the looks of things that last php tag is not closed. This could cause your page to stop loading.

  3. #3
    hakermania's Avatar
    hakermania is offline Τώρα ξέρεις τι γράφω εδώ!
    Join Date
    Aug 2009
    Location
    Greece
    Beans
    1,704
    Distro
    Ubuntu Development Release

    Re: PHP multiple forms submission

    This was a copy error actually
    This isn't the problem
    Website

    Wallch (Wallpaper Changer): Sourceforge | Launchpad

Bookmarks

Posting Permissions

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