SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Help needed...

  1. #1
    SitePoint Member
    Join Date
    Oct 2002
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help needed...

    How can i make a php script that allows me to fill in some fiels in the admin page and display them on a html file in my webpage?

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Your question is too vague. Where is the data from the admin page going to be stored? Where is the HTML page going to get the information from?

    Try to explain your thoughts a bit better.
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    SitePoint Member
    Join Date
    Oct 2002
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    k, what i mean...
    In the admin page, i need some sort of form, that sends the data that's filled in to the database...
    Then when it's in the database, the .php page or .html page needs to get the info from the database (mysql) and put it on the website in a table...

  4. #4
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    The form is a simple HTML form, it is the page which actions the form which needs the PHP (it can be the same page). Here is some example PHP code to do the INSERT into the database.

    PHP Code:
    if ($_POST["adminsubmit"] == "Submit") {
      
    $username $_POST["username"];
      
    $password $_POST["password"];
      
    $emailaddr $_POST["emailaddr"];

      
    $conn mysql_connect ("localhost","YourMySQLUsername","YourMySQLPassord")
        or die (
    "Could not connect");
      
    mysql_select_db ("YourMySQLDatabaseName")
        or die (
    "Database not found.");

      
    $sql "INSERT INTO YourTableName (UsernameField,PasswordField,EmailField) VALUES ('$username','$password','$emailaddr')";
      
    mysql_query ($sql)
        or die (
    mysql_error());

    This example assumes you have a submit button like ...

    <input type="submit" name="adminsubmit" value="Submit" />

    ... and text form elements called username, password and emailaddr. Note: I have done virtually no validation on the data in this example.

    I recommend you read the mySQL chapter of the PHP manual - you will learn a lot from it.
    Ian Anderson
    www.siteguru.co.uk


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
  •