Forum Moderators: coopster

Message Too Old, No Replies

form error

         

bobnew32

6:03 am on Aug 12, 2003 (gmt 0)

10+ Year Member



Ok i have the following script that adds a row to a database. It worked fine with the original submit tag, but when I tried to jazz it up, it stopped working!

Code to detect the submit button:

if($submit) //If submit is hit
{


$result=MYSQL_QUERY("INSERT INTO user_mail (id,name,email,url,message)".

And heres the submit button #1 that worked:

<input type="submit" name="submit">

And heres the second one that didnt work:

<input type="submit" name="submit" style="background-image: url(images/sendmail.gif); border: 0; width: 51px; height: 23px; background-color: transparent;" value="" onMouseOver="this.style.cursor='hand';">

Thx

vincevincevince

7:27 am on Aug 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't see why that would break it. I recommend now going back to the un-jazzed button and checking it really IS the problem, not something else you've done. Try changing $submit to $_REQUEST['submit'] as well, although that shouldn't be the problem.

Paul in South Africa

1:11 pm on Aug 12, 2003 (gmt 0)

10+ Year Member



I'm not sure whether I have the right idea here or not, being a relative newcomer to PHP, but here goes anyway.

As I understand the if conditional operator in PHP it will evaluate whatever to its Boolean value. In this case $submit will evaluate to false because you have set value="" in your submit button. An empty string will evaluate to the Boolean false.

To fix the problem either specify a value other than an empty string in your submit button code or use if(isset ($submit)) as the conditional test.

hakre

2:43 pm on Aug 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



@Paul in South Africa:
even if you're 'relativly' new to php, you found the main problem.

@all:
i can only confirm to that the isset($submit) function is able to check wether the submit button has been pressed or not. this will even prevent the display of warning messages if submit is not pressed at all.

bobnew32

7:21 pm on Aug 12, 2003 (gmt 0)

10+ Year Member



Thx guys the if(isset ($submit)) worked great!