Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder GSimpson's Avatar
    Join Date
    Aug 2006
    Location
    New Zealand
    Posts
    268
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Form As Variable

    Ok so,
    I have a script that inserts a variable into the database,
    so how do i make my form my variable,
    i know that with js its like this:
    var name=document.formname.inputname.value;

    is this a legal php one?

    $name=doument.formname.inputname.value;

    thanks
    The internet is my Sandbox, and notepad is my Spade n' Bucket.

  • #2
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    The form has to be submitted to a php script but then it would be accessed like
    PHP Code:
    <?
    $name 
    $_POST['inputname'];
    //or $_GET if form method is get instead of post
    ?>

  • #3
    Regular Coder GSimpson's Avatar
    Join Date
    Aug 2006
    Location
    New Zealand
    Posts
    268
    Thanks
    9
    Thanked 0 Times in 0 Posts
    thanks!!! however, I have encountered another problem, now this is a bit off topic but i want to send a variable to a table. will this work?

    <?php
    //records username and password into database
    $username=$_POST["username"];
    $password=$_POST["password"];
    $con = mysql_connect("mysql2.freehostia.com","glysim_userpass","******");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }

    mysql_select_db("glysim_userpass", $con);

    mysql_query("INSERT INTO usernames (username, password)
    VALUES ($username, $password)");
    mysql_close($con);
    ?>
    thanks again
    The internet is my Sandbox, and notepad is my Spade n' Bucket.

  • #4
    Regular Coder GSimpson's Avatar
    Join Date
    Aug 2006
    Location
    New Zealand
    Posts
    268
    Thanks
    9
    Thanked 0 Times in 0 Posts
    C'mon!!!!
    The internet is my Sandbox, and notepad is my Spade n' Bucket.

  • #5
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Instead of asking us if it will work, why not just try it and see?

  • #6
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Below is what I use. It's a quick cut and paste but easy to figure out, I'm sure there is other variations that will also work.


    PHP Code:
    mysql_query("INSERT INTO canadastore (item_catagory, item_image,
    item_title, item_description, item_price, item_location, item_email, item_date)
    VALUES ('$_POST[catagory]', '$_POST[date_image]', '$_POST[item_title]',
    '$_POST[item_description]', '$_POST[item_price]', '$_POST[item_location]',
    '$_POST[item_email]', '$_POST[item_date]') "
    )
    or die(
    mysql_error()); 
    Leonard Whistler

  • #7
    Regular Coder GSimpson's Avatar
    Join Date
    Aug 2006
    Location
    New Zealand
    Posts
    268
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Thanks for everyones input, but now i'm finished.
    The internet is my Sandbox, and notepad is my Spade n' Bucket.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •