Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: Problem with Dreamweaver Trying to get A Dynamic Data...

  1. #1
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default Problem with Dreamweaver Trying to get A Dynamic Data...

    Answer is on page 3... posted by myself...
    Last edited by Rockonmetal; 07-15-2007 at 03:04 AM.

  2. #2
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    Give me a minute, Bravenet doesn't like me... i'll put it on freewebs...

  3. #3
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    The connection name would be the name you give for your MySQL database connection. Your database server (beings that you installed WAMP5) would be "localhost" (without the quotes). The username and password by default is "root" (again, no quotes) with no password. The database will be the database that you have set up using either the MySQL command line tools or using PHPMyAdmin (which I believe comes preinstalled with WAMP5).

    Hope this helps.

    //EDIT (after reading what's below the last image in your post): Not sure how you would do it in Dreamweaver, but if you were to make your own php script to write to files, you may want to look through these pages for any understanding on how to do so:

    http://www.php.net/fopen
    http://www.php.net/fwrite
    http://www.php.net/file_get_contents
    http://www.php.net/fclose
    (and so on...)
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  4. #4
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    Ok the images are up... anyone willing to help me out here, let me know...

    Thanks to all

    ok i'll try that...

    What should go in connection name?
    Edit:
    I just installed WAMP5 Onto my computer and I haven't found how to name my server or change the username and password...

    Ok I think I might just have a way to bypass the who binding thing...

    I'll put up the code i have
    Last edited by thetestingsite; 07-08-2007 at 09:19 PM.

  5. #5
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    PHP Code:
    <?php
    $filename 
    'data.txt';
    $somecontent "Add this to the file\n";

    // Let's make sure the file exists and is writable first.
    if (is_writable($filename)) {

        
    // In our example we're opening $filename in append mode.
        // The file pointer is at the bottom of the file hence
        // that's where $somecontent will go when we fwrite() it.
        
    if (!$handle fopen($filename'a')) {
             echo 
    "Cannot open file ($filename)";
             exit;
        }

        
    // Write $somecontent to our opened file.
        
    if (fwrite($handle$somecontent) === FALSE) {
            echo 
    "Cannot write to file ($filename)";
            exit;
        }

        echo 
    "Success, wrote ($somecontent) to file ($filename)";

        
    fclose($handle);

    } else {
        echo 
    "The file $filename is not writable";
    }
    ?>
    Theres the code... it wrote it into the document data.txt
    Ok, now how do I get that to write the entire form into the document?

  6. #6
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    You would need to put the code you posted into a php document, and to write the contents of the form to the file, you will need to request the content like so:

    Code:
    <?php
    $filename = 'data.txt';
    
    $formfield = $_POST['field1'];
    
    /* The above can be $_POST, $_GET, or $_REQUEST depending on the way you 
    are submitting the form. field1 (inside the $_POST array) is the name of the field 
    in which you are requesting the data from. the variable $formfield is just a variable. */
    
    $somecontent = "This is a test. $formfield \r\n";
    
    
    
    // Let's make sure the file exists and is writable first.
    if (is_writable($filename)) {
    
        // In our example we're opening $filename in append mode.
        // The file pointer is at the bottom of the file hence
        // that's where $somecontent will go when we fwrite() it.
        if (!$handle = fopen($filename, 'a')) {
             echo "Cannot open file ($filename)";
             exit;
        }
    
        // Write $somecontent to our opened file.
        if (fwrite($handle, $somecontent) === FALSE) {
            echo "Cannot write to file ($filename)";
            exit;
        }
    
        echo "Success, wrote ($somecontent) to file ($filename)";
    
        fclose($handle);
    
    } else {
        echo "The file $filename is not writable";
    }
    ?>
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  7. #7
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    So Field1 Is set as the Form name or the inputs?

  8. #8
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    It would be the field in the form that you want the data from. Example:

    The form:
    Code:
    <form action="test.php" method="POST">
    <input type="text" name="testField">
    <input type="submit" value="Go">
    </form>
    The PHP script:
    Code:
    <?php
    
    $var = $_POST['testField'];
    
    echo $var; //echos whatever was typed into the text field named testField
    ?>
    Hope this helps.

    //EDIT: Also, the fields need to be spelled the exact same in both the form and the php script for it to work properly.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  9. #9
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    Sweet Thanks alot! one question though. Can I do this?
    Code:
    $var = $_POST['testField' , 'testField2'];
    ?? Or do I have to put in entirely different code for that.

  10. #10
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    You would have to call the field in individual statements like so:

    Code:
    <?php
    
    $name = $_POST['name'];
    $email = $_POST['email'];
    or simply call the field like so if you are just going to use it once in the script:

    Code:
    <?php
    
    echo $_POST['name'] . " <br> " . $_POST['email'];
    
    //will display something like Name <br> Email in the source code.
    ?>
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

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
  •