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 5 of 5

Thread: form

  1. #1
    New Coder
    Join Date
    Feb 2007
    Posts
    92
    Thanks
    1
    Thanked 0 Times in 0 Posts

    form

    I have a form and on text field on it
    In the action of the form i want to use the value of the field in the header.
    How do i get this value from the form

    Here is the code

    Code:
    <form action="cart.php?qty=<?php echo $_POST['qty']; >" method="post" name="form1" class="style15">
    <p><strong>Quantity</strong>:<input name="qty" type="text" id="qty" value="1" size="2" maxlength="4"></p>
    <p><input name="Submit" type="submit" value="Add to Cart"></p>
    </form>
    i have used $_POST but i dont know if this will take data from the previous page.

    Thanks

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Use better descriptions in your subject title. 'Form' doesn't mean anything.

    You'll be best to use GET

    Code:
    <form action="cart.php" method="get" name="form1" class="style15">
    <p><strong>Quantity</strong>:<input name="qty" type="text" id="qty" value="1" size="2" maxlength="4"></p>
    <p><input name="Submit" type="submit" value="Add to Cart"></p>
    </form>

  • #3
    New Coder
    Join Date
    Feb 2007
    Posts
    92
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks but to get the value of the "qty" textfield into the url in the form action how do i do that is it

    <form action = "cart.php?qty=<?php echo $_GET['qty']; ?>"

  • #4
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    It goes into the url automatically. Try the example I gave you

  • #5
    New Coder
    Join Date
    Feb 2007
    Posts
    92
    Thanks
    1
    Thanked 0 Times in 0 Posts
    great i didnt realise that
    thank you!


  •  

    Posting Permissions

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