Need MYSQL help: phpMyAdmin

Discussion in 'Programming' started by GameOver, Feb 24, 2008.

  1. #1
    I am using phpMyAdmin to create databases. I need a very basic guide in these areas: i) how do you make a form that uploads information and ii) how do I make a simple searching mechanism. Assume I know nothing. I would appreciate any help. thanks.
     
    GameOver, Feb 24, 2008 IP
  2. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #2
    to upload info you need to create a form like this with name form.php

    <html>
    <body><form action="insert.php" method="post">
    Firstname: <input type="text" name="firstname" />
    Lastname: <input type="text" name="lastname" />
    Age: <input type="text" name="age" />
    <input type="submit" />
    </form></body>
    </html>

    then create a second file insert.php

    <?php
    $con = mysql_connect("localhost","yourmysqldbusername","yourmysqldbpassword");

    //localhost refers to your server name and its normally localhost ,for godaddy and some other hosts its
    // not localhost


    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }mysql_select_db("yourmysqldbname", $con);$sql="INSERT INTO person (FirstName, LastName, Age)
    VALUES
    ('$_POST[firstname]','$_POST[lastname]','$_POST[age]')";if (!mysql_query($sql,$con))
    {
    die('Error: ' . mysql_error());
    }
    echo "1 record added";mysql_close($con)
    ?>
     
    kmap, Feb 24, 2008 IP