...

View Full Version : Not sure what is wrong...



SirSteve
03-26-2007, 06:33 PM
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

rafiki
03-26-2007, 06:42 PM
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

_Aerospace_Eng_
03-26-2007, 06:44 PM
You use

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

<input type="submit" value="Submit" onClick="return checkForm();" />
to this

<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?

Krokador
03-26-2007, 06:49 PM
I think I know what's wrong with your page.

you use

if(isset($_POST['Submit'])

you are trying to check the value of an input you havent named (or given and id)

<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*

SirSteve
03-26-2007, 08:21 PM
You were both correct! Thanks!

Nightfire
03-26-2007, 08:43 PM
I think I know what's wrong with your page.

you use

if(isset($_POST['Submit'])

you are trying to check the value of an input you havent named (or given and id)

<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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum