[PHP] sending data to two tables.
Hey, This time it's not about missing quotes or parenthasies i hope. I'm trying to make a form which sends name, email, website, favsong and comments to table guestbook, but when the checkbox mailinglist is checked it should send the name and email to table mailinglist, but it doesn;t seem to work. any pointers? Jule --SCRIPT-- ?php $Guestbook[dateadd] = date(F j, Y); $Guestbook[name] = trim($Guestbook[name]); $Guestbook[town] = trim($Guestbook[town]); $Guestbook[email] = trim($Guestbook[email]); $Guestbook[website] = trim($Guestbook[website]); $Guestbook[favsong] = trim($Guestbook[favsong]); $Guestbook[comments] = trim($Guestbook[comments]); $Guestbook[mailinglist] = trim($Guestbook[mailinglist]); $Host = localhost; $User = ; $Password = *; $DBName = blindtheory; $TableName = guestbook; $TableName2 = mailinglist; $Pattern = .+@.+..+; $Pattern2 = (http://)?([^[:space:]]+)([[:alnum:]\.,-_?/=]); $Link = mysql_connect ($Host, $User, $Password); $Query = INSERT into $TableName values('0', '$Guestbook[dateadd]', '$Guestbook[name]', '$Guestbook[town]', '$Guestbook[email]', '$Guestbook[website]','$Guestbook[favsong]', '$Guestbook[comments]'); $Query2 = INSERT into $TableName2 values('0', '$Guestbook[dateadd]', '$Guestbook[name]', '$Guestbook[email]'); if (mysql_db_query ($DBName, $Query, $Link)) { echo Your entry will be addedbrClick a href=../index.php?left=guestbookrighttop=guestbookrightbottom=guestbookrttitle=mailinglistrbtitle=gbaddhere/a to go back.; } else { echo There was an error in during the posting, please contact a href=\mailto:[EMAIL PROTECTED]\;the webmaster/a and he will fix the problem.br; } mysql_close ($Link); if (isset($Guestbook[mailinglist])) { if (mysql_db_query ($DBName, $Query2, $Link)) { echo Your e-mail address was sucessfully added to our mailinglist; } else { echo Your e-mail address will not be added to the mailinglist; } } mysql_close ($Link); ? -- Jule Slootbeek [EMAIL PROTECTED] http://blindtheory.cjb.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sending data to two tables.
On Wednesday 01 May 2002 07:34, Jule wrote: Hey, This time it's not about missing quotes or parenthasies i hope. I'm trying to make a form which sends name, email, website, favsong and comments to table guestbook, but when the checkbox mailinglist is checked it should send the name and email to table mailinglist, but it doesn;t seem to work. We're not physic! How doesn't it work? -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* A well-known friend is a treasure. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sending data to two tables.
I don't know, every time i submit the form w/ the checkbox checked. it gives me the echo string which comes when the if is not executed..it adds the entries from the form to the guestbook table, but doesn't add the name and email to the mailinglist table. it doesn't give me any php or mysql errors. Jule On Tuesday 30 April 2002 23:35, you wrote: On Wednesday 01 May 2002 07:34, Jule wrote: Hey, This time it's not about missing quotes or parenthasies i hope. I'm trying to make a form which sends name, email, website, favsong and comments to table guestbook, but when the checkbox mailinglist is checked it should send the name and email to table mailinglist, but it doesn;t seem to work. We're not physic! How doesn't it work? -- Jule Slootbeek [EMAIL PROTECTED] http://blindtheory.cjb.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sending data to two tables.
So it executed the first if: if (mysql_db_query ($DBName, $Query, $Link)) { echo Your entry will be addedbrClick a href=../index.php?left=guestbookrighttop=guestbookrightbottom=guestbookrttitle=mailinglistrbtitle=gbaddhere/a to go back.; } else { echo There was an error in during the posting, please contact a href=\mailto:[EMAIL PROTECTED]\;the webmaster/a and he will fix the problem.br; } mysql_close ($Link); but not the second one: if (isset($Guestbook[mailinglist])) { if (mysql_db_query ($DBName, $Query2, $Link)) { echo Your e-mail address was sucessfully added to our mailinglist; } else { echo Your e-mail address will not be added to the mailinglist; } } mysql_close ($Link); and yes, i am sure the checkbox is checked. Jule On Tuesday 30 April 2002 23:43, you wrote: I don't know, every time i submit the form w/ the checkbox checked. it gives me the echo string which comes when the if is not executed..it adds the entries from the form to the guestbook table, but doesn't add the name and email to the mailinglist table. it doesn't give me any php or mysql errors. Jule On Tuesday 30 April 2002 23:35, you wrote: On Wednesday 01 May 2002 07:34, Jule wrote: Hey, This time it's not about missing quotes or parenthasies i hope. I'm trying to make a form which sends name, email, website, favsong and comments to table guestbook, but when the checkbox mailinglist is checked it should send the name and email to table mailinglist, but it doesn;t seem to work. We're not physic! How doesn't it work? -- Jule Slootbeek [EMAIL PROTECTED] http://blindtheory.cjb.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sending data to two tables.
On Wednesday 01 May 2002 11:48, Jule wrote: but not the second one: if (isset($Guestbook[mailinglist])) { You should be using: if (isset($Guestbook['mailinglist'])) { if (mysql_db_query ($DBName, $Query2, $Link)) { echo Your e-mail address was sucessfully added to our mailinglist; } else { echo Your e-mail address will not be added to the mailinglist; } Are you saying that the else clause gets executed, so you get Your e-mail address will not be added to the mailinglist? If so then your error is within: if (mysql_db_query ($DBName, $Query2, $Link)) Therefore: 1) add some error checking code -- see examples in manual and also mysql_error(). 2) echo your queries ($Query2) -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* The meeting of two personalities is like the contact of two chemical substances: if there is any reaction, both are transformed. -- Carl Jung */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sending data to two tables.
Alright i'll take care of that, thanks a lot! Jule On Wednesday 01 May 2002 00:26, you wrote: On Wednesday 01 May 2002 11:48, Jule wrote: but not the second one: if (isset($Guestbook[mailinglist])) { You should be using: if (isset($Guestbook['mailinglist'])) { if (mysql_db_query ($DBName, $Query2, $Link)) { echo Your e-mail address was sucessfully added to our mailinglist; } else { echo Your e-mail address will not be added to the mailinglist; } Are you saying that the else clause gets executed, so you get Your e-mail address will not be added to the mailinglist? If so then your error is within: if (mysql_db_query ($DBName, $Query2, $Link)) Therefore: 1) add some error checking code -- see examples in manual and also mysql_error(). 2) echo your queries ($Query2) -- Jule Slootbeek [EMAIL PROTECTED] http://blindtheory.cjb.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php