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 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Not sure what is wrong...

    I am trying to learn PHP and mySQL and have a simple wishlist but I cannot see where the bug is. When I click Submit, it doesn't add the data to the database. No errors, Here is the URL:

    http://www.zodesigns.com/wishlist/wishlist.php

    and attached is the source code.

    Any help would be appreciated.

    Thanks
    Last edited by WA; 04-05-2009 at 05:36 AM.

  • #2
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    is short tags allowed? i wouldnt recommend using them even if they are, also set error reporting to strict, i didnt read all of your code, but if you use a syntax highlighting editor you will see the syntax errors if any

  • #3
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    You use
    PHP Code:
    isset($_POST['Submit']) 
    but yet you have no input with name="Submit" so your first if statement is never being met which is why it doesn't submit anything to the database. If you changed this
    PHP Code:
    <input type="submit" value="Submit" onClick="return checkForm();" /> 
    to this
    PHP Code:
    <input type="submit" value="Submit" name="Submit" onClick="return checkForm();" /> 
    Then it should work.

    Also you do know you can post code in the forums directly don't you?
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #4
    New Coder
    Join Date
    Mar 2007
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think I know what's wrong with your page.

    you use
    PHP Code:
    if(isset($_POST['Submit']) 
    you are trying to check the value of an input you havent named (or given and id)
    PHP Code:
    <input type="submit" value="Submit" onClick="return checkForm();" /> 
    just add name="Submit" id="Submit" in that tag and it should work

    *edit* It seems i was beaten in speed by someone else lol... */edit*
    Last edited by Krokador; 03-26-2007 at 06:19 PM.

  • #5
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You were both correct! Thanks!

  • #6
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Quote Originally Posted by Krokador View Post
    I think I know what's wrong with your page.

    you use
    PHP Code:
    if(isset($_POST['Submit']) 
    you are trying to check the value of an input you havent named (or given and id)
    PHP Code:
    <input type="submit" value="Submit" onClick="return checkForm();" /> 
    just add name="Submit" id="Submit" in that tag and it should work

    *edit* It seems i was beaten in speed by someone else lol... */edit*
    PHP doesn't use the id tag, so no need to add that. It's clientside ie css, javascript,etc that makes use of that


  •  

    Posting Permissions

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