SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Sep 2004
    Location
    japan
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problems passing a variable from a form to a new page

    Hi there, I'm a huge PHP neophyte, and I'm having problems passing a variable to a new php page

    Page #1 looks like this (I am pulling values for a popup box from database #1)

    <?php
    $dbcnx = @mysql_connect('localhost', 'root', 'password');
    if (!$dbcnx) {
    die( '<p>Unable to connect to the ' .
    'database server at this time.</p>' );
    }

    // Select the companys database
    if (! @mysql_select_db('mbratings') ) {
    die( '<p>Unable to locate the ratings ' .
    'database at this time.</p>' );
    }
    $sql = "SELECT name FROM companies ORDER BY name";
    $result = mysql_query ($sql); ?>

    <form action="form2.php" method="post">
    <select name="company">
    <?php
    while ($row = mysql_fetch_object ($result)) {
    $catname = $row ->name;
    echo '<option value="'.$catname.'">'.$catname.'</option>';
    }
    echo '</select>';
    echo '<p><input type="submit" name="submitcompany"></p>';
    echo '</form>';
    ?>

  2. #2
    SitePoint Zealot ashutosh_sns's Avatar
    Join Date
    Aug 2004
    Location
    New Delhi , india
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    u can get the values on the second page by post array
    Code:
    $company=$_POST['company'];
    when u post data on any page all the post element values store in $_POST array
    note:PHP is case sensitive so take care about it. Capital and small makes a large difference.
    Ashutosh Tripathi
    Home Page


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
  •