Table contents not updated
| From: | Wikus Moller | Date: | Mon, 08 Jan 2007 17:13:12 +0000 |
| Subject: | Table contents not updated | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-246765@lists.php.net to get a copy of this message | ||
Hi.
I am new to uising html forms with php and I am having a problem with
database contents not being updated although it seems my coding is
correct.
It's a xhtml formatted site with html forms:
Here are my functions:
<?
function login($uid, $pwd)
{
$pass = md5($pwd);
$pasw = mysql_fetch_array(mysql_query("SELECT pass FROM members
WHERE name='".$uid."'"));
$dbpw = $pasw[0];
if($pass == $dbpw)
{
$banned=mysql_fetch_array(mysql_query("SELECT * FROM members WHERE
banned='1' and name='".$uid."'"));
if($banned)
{
return 2;}else{
return 0;} }else{ return 1; } } function edtsite($username,$pass,$snm,$lnk,$imgu,$catg,$uid,$dsc,$keywords,$weblnk,$sid)
{
if (login($username,$pass)==0)
{
$adds=mysql_query("UPDATE sub_sites SET
sitename='".$snm."', sitelink='".$lnk."', sitelogo='".$image."',
catid='".$catg."', uid='".$uid."', dscr='".$dsc."',
keywords='".$keywords."', weblink='".$weblnk."' WHERE id='".$sid."'");
if ($adds) {
return true;
} else {
return false ;
}
}else{
return false;
}
}
?>
Everything seems to be correct, but the table isn't updated...
<?
echo "<form method=\"post\"
action=\"editsitefin.php?uid=$uid&pwd=$pwd&sid=$sid\">";
echo "*Site Name: <input type=\"text\" name=\"snm\" maxlength=\"30\"
size=\"10\" value=\"$sites[1]\"/><br/>";
echo "*Wap Link: <input type=\"text\" name=\"lnk\" maxlength=\"200\"
size=\"10\" value=\"$sites[3]\"/><br/>";
echo "Web Link: <input type=\"text\" name=\"weblnk\"
maxlength=\"200\" size=\"10\" value=\"$sites[14]\"/><br/>";
echo "Logo URL: <input type=\"text\" name=\"imgu\" maxlength=\"200\"
size=\"10\" value=\"$sites[4]\"/><br/>";
echo "*Description: <input type=\"text\" name=\"dsc\"
maxlength=\"200\" size=\"10\" value=\"$sites[11]\"/><br/>";
echo "*Category:";
echo "<select name=\"catg\" value=\"$sites[2]\">";
echo "<option value=\"1\">Entertainment</option>";
echo "<option value=\"2\">Portal - Search</option>";
echo "<option value=\"3\">Messaging - Chat</option>";
echo "<option value=\"4\">Ringtones - Logos</option>";
echo "<option value=\"5\">Fun - Games</option>";
echo "<option value=\"6\">Hobbies - Interests</option>";
echo "<option value=\"7\">Services</option>";
echo "<option value=\"8\">Personal</option>";
echo "<option value=\"9\">Others</option>";
echo "</select><br/>";
echo "*Keywords: (separate by spaces)<input type=\"text\"
name=\"keywords\" maxlength=\"200\" size=\"20\"
value=\"$sites[13]\"/><br/>";
echo "* = Denotes a required field.<br/>";
echo "<input type=\"submit\" name=\"add\" value=\"Edit\"/>";
echo "</form>";
?>
Theres my form, also everything seems to be correct... The correct
values are displayed when the form is loaded.
<?
$uid=$_GET["uid"];
$pwd=$_GET["pwd"];
$snm = $_POST["snm"];
$lnk = $_POST["lnk"];
$imgu = $_POST["imgu"];
$catg = $_POST["catg"];
$dsc = $_POST["dsc"];
$weblnk = $_POST["weblnk"];
$keywords = $_POST["keywords"];
$sid = $_POST["sid"];
$uidid = mysql_fetch_array(mysql_query("SELECT * from members where
name='".$uid."';"));
$res = edtsite($uid,$pwd,$snm,$lnk,$imgu,$catg,$uidid[0],$dsc,$keywords,$weblnk,$sid);
$snm=htmlspecialchars($snm);
if ($res) {
$stid = mysql_fetch_array(mysql_query("SELECT * from sub_sites
where sitelink='".$lnk."';"));
echo "<head>";
metatags();
echo "<title>Chilling Lounge.net</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">";
echo "</head>";
echo "<body>";
echo "<table>";
echo "<div class=\"cre\">";
echo "$snm Updated Successfully</div>";
?>
And theres my site finished page (editsitefin.php), I can't find any
errors, but I am not that clued up with html forms. Does anyone notice
any errors? It displays a success message yet when I look at the
database or when I browse again to the site, the info isn't updated.
Please check if you find any errors that could cause the database
fields not to be updated or suggest a possible fix
Thanks