sending data to two tables.
| From: | Jule | Date: | Tue, 30 Apr 2002 23:34:05 +0000 |
| Subject: | sending data to two tables. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-95452@lists.php.net to get a copy of this message | ||
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 "<p><p><p><p>Your entry will be added<br>Click <a
href=../index.php?left=guestbook&righttop=guestbook&rightbottom=guestbook&rttitle=mailinglist&rbtitle=gbadd>here</a>
to go back.<p><p><p><p>";
} else {
echo "There was an error in during the posting, please contact <a
href=\"mailto:webmaster@blindtheory.cjb.net\">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
jslootbeek@clarku.edu
http://blindtheory.cjb.net