Welcome our webmaster and SEO forum
Please enjoy the forum, contribute what you can, and wind up the Moderators!
Results 1 to 3 of 3

Thread: Complete beginner - Does anyone want to answer my stupid questions?

  1. #1
    StevieB is offline Junior Member
    Join Date
    Aug 2007
    Posts
    5

    Question Complete beginner - Does anyone want to answer my stupid questions?

    Hi,
    Thanks for reading. I'm a complete beginner and really nead some help. I'm trying to develop a brand new website but need help on the php/html/mysql side of things.

    1'st stupid question ~
    i want to collect customers' text input on a HTML screen and store it to put it into an output from a php script accesing a mysql database.

    will

    <h4>Input here</h4>
    <form action="my website address" method="post">
    <input type="text" name="color" id="color"/>
    <input type="submit" value="Click"/>
    </form>

    work????

    will this collect the text?
    where does it store it?
    can I do this with up to 4 different txt inputs at the same time?

    thanks

    Steve

  2. #2
    imported_misi Guest

    Default

    Your form is okay. What you need to do is to create your database on what you will save the submitted data and also to point your form 'action' to a simple php script what connect to your database and insert on this the submitted data.

    1. Your Form (for example send.html):
    <h4>Input here</h4>
    <form action="processing.php" method="post">
    <input type="text" name="color" id="color"/>
    <input type="text" name="size" id="size"/>
    <input type="submit" value="Click"/>
    </form>

    2. The script (processing.php)
    <?php
    $hostname_example = "localhost";
    $database_example = "your_database_name";
    $username_example = "your_database_username";
    $password_example = "your_database_password";
    $example = mysql_pconnect($hostname_example, $username_example, $password_example) or trigger_error(mysql_error(),E_USER_ERROR);
    mysql_select_db($database_example, $example);
    $result = mysql_query ("INSERT INTO your_database_table_name (color, size) VALUES('$color', '$size')");
    ?>
    3. For the above example on the datbase you will need to crete one table and to add to this the below fields:
    - color
    - size

  3. #3
    StevieB is offline Junior Member
    Join Date
    Aug 2007
    Posts
    5

    Question

    Hey thanks for that , but I think I mislead, I don't want to permanently store the info, just hold it for a while, collect some text from the database and substitute the inputted text where HHHH and EEEE appear ~

    a friend got me as far as this (then buggered off and i can't contact her)but it doesn't work and I can't seem to get it to work. What's wrong with the script cos it's got me stumped. :sCo_idk4: It did work locally on her PC (that's why I asked the first question cos I thought it might be something to do with the html.)

    -----------------------------------------------------------------------

    The database has text and also HHHH and EEEE in the places where I want to put the gathered text ~






    <h4>Input here</h4>
    <form action="address of website and name of php code" method="post">
    <input type="text" name="color" id="color"/>
    <input type="submit" value="Click"/>
    </form>
    </body>
    <?php

    // Connect to a MySQL server
    $link = mysql_connect(
    'hostname', // The host to connect to
    'User', // The user to connect as
    'password', //The password to use
    'database'); // The default database to query
    //If connection not made successfully show error message
    if (!$link) {
    printf("Can't connect to MySQL Server. Errorcode: %s\n", mysql_connect_error());
    exit;
    }
    $query = 'SELECT * FROM table name ORDER BY RAND() LIMIT 1';
    for($i = 0; $i <= 2; $i++){
    // Send a query to the server
    if ($result = mysql_query($link,$query)) {
    // Fetch the results of the query
    while( $row = mysql_fetch_row($result) ){
    $row = str_replace('EEEE', 'HHHH', $row);
    $joinedstr =$row[$i];
    printf("%s", $row[$i]);
    //printf("%s", $row[0]);
    //printf("%s", $bodytag[i]);
    echo "</br>";
    }
    printf("%s", $joinedstr);
    // Destroy the result set and free the memory used for it
    mysql_free_result($result);
    }
    }
    // Close the connection
    mysql_close($link); */


    // Connect to a MySQL server
    $link = mysql_connect(
    $host, // The host to connect to
    $usr, // The user to connect as
    $pw //The password to use
    );
    //If connection not made successfully show error message
    if (!$link) {
    printf("Can't connect to MySQL Server. Errorcode: %s\n", mysql_connect_error());
    exit;
    }
    $db=mysql_select_db($db,$link)
    or die ("Couldn't select database.");

    $query = 'SELECT * FROM table name ORDER BY RAND() LIMIT 1';
    //$color=$_POST['color'];
    for($i = 0; $i <= 2; $i++){
    // Send a query to the server
    if ($result = mysql_query($query)) {
    // Fetch the results of the query
    while( $row = mysql_fetch_row($result) ){
    //$row = str_replace('EEEE',$color , $row);
    printf("%s", $row[$i]);
    echo "</br></br></br>";
    }

    // Destroy the result set and free the memory used for it
    mysql_free_result($result);
    }
    }
    // Close the connection
    mysql_close($link);
    ?>
    </html>

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Is CMS the answer?
    By temi in forum General Webmaster Talk
    Replies: 12
    Last Post: 12-08-2007, 06:50 AM
  2. I am a new guy and not a beginner
    By seo8k in forum General Webmaster Talk
    Replies: 7
    Last Post: 09-20-2007, 06:41 AM
  3. Prolly a stupid idea but...
    By Duke in forum General Webmaster Talk
    Replies: 31
    Last Post: 08-04-2005, 07:56 PM
  4. Beginner
    By mixhouse in forum General Webmaster Talk
    Replies: 17
    Last Post: 10-29-2004, 10:37 PM

Bookmarks

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124