[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] SQL update queries in a [perl] tag
Hello List,
I have a form taht sends the variable login_email to another page, with this
code on it. The purpose is to update a persons username, since we encourage
people to use their email addresses as their username.
The problem is my SQL query. I've loaded $sql_req with all the proper query
lines, but can't find a way to execute the query without breaking something.
Any ideas would be great.
Thanks,
Russ
[perl interpolate=1 global=1 tables="userdb ship_addresses transactions
orderline"]
my @tables = (
"userdb",
"ship_addresses",
"transactions",
"orderline"
);
my $sql_req = '';
$login_email = "$Values->{login_email}";
$old_username = "$Session->{username}";
if ($login_email eq $old_username) {
return "<b>$login_email</b> is the same as <b>$old_username</b>. No update
performed.";
} else {
#$sql_isitused = "SELECT username FROM userdb WHERE username =
'$login_email'";
#$Tag->query($sql_isitused, $ATTRHASH, $BODY);
if (!($Tag->data('userdb', 'username', $login_email ))) {
foreach $table(@tables) {
$sql_req .= "UPDATE $table SET username = '$login_email' WHERE username =
'$old_username';\n";
}
#$Tag->query($sql_req, $ATTRHASH, $BODY);
return "
$sql_req<br>
Your login email address has been changed to <b>$login_email</b>. You will
need to
<a href=\"[area login]\">Login</a> again with your new address.
";
} else {
return "<b>$login_email</b> is already in use. If you have more than one
account with us,
please email <a href=\"[area help/contact]\">Customer Service</a> to get
this resolved.";
}
}
[/perl]