Reputation: 58
I have this function and when I update the data I still have the same problem . I don't know where is the error. By the way my connection file is true
This is the message i put it :
Site name Error
This is my code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
<link href="style.css" rel="stylesheet" type="text/css" />
<title>Admin control</title>
</head>
<body>
</body>
<div class="head">Settings</div>
<?
/*
CREATE TABLE `article`.`setting` (
`name_site` VARCHAR( 300 ) NOT NULL ,
`url_site` VARCHAR( 300 ) NOT NULL ,
`email_site` VARCHAR( 150 ) NOT NULL ,
`desc_site` TEXT NOT NULL ,
`kay_site` TEXT NOT NULL ,
`oepn_site` MEDIUMINT( 2 ) NOT NULL ,
`text_close_site` TEXT NOT NULL
) ENGINE = InnoDB;
*/
include "../include/config.php";
if (isset($_POST['submit'])){
$ns = $_POST['name_site'];
$us = $_POST['url_site'];
$es = $_POST['email_site'];
$ds = $_POST['desc_site'];
$ks = $_POST['kay_site'];
$os = $_POST['oepn_site'];
$ms = $_POST['text_close_site'];
}
if (@$_POST['updatesetting']){
if(@$ns == ''){
echo "<div class='no'> Site name Error </div>";
echo '<meta http-equiv="refresh" content="2; url=setting.php"/>';
exit;
}
else {
$update = mysql_query("update setting set
name_site='$ns',
url_site = '$us',
email_site = '$es',
desc_site = '$ds',
kay_site = '$ks',
oepn_site = '$os',
text_close_site ='$ms'
") ;
if (@isset($update)){
echo "<div class='ok'> Update Done</div>";
echo '<meta http-equiv="refresh" content="2; url=setting.php"/>';
exit;
}
}
}
$sel1 = mysql_query("select * from setting ");
$row1 = mysql_fetch_assoc($sel1);
$name_site = $row1['name_site'];
$url_site = $row1['url_site'];
$email_site = $row1['email_site'];
$desc_site = $row1['desc_site'];
$kay_site = $row1['kay_site'];
$oepn_site = $row1['oepn_site'];
$text_close_site = $row1['text_close_site']
?>
<div class="bodypanel">
<form action="setting.php" method="post">
<table width="100%" border="0" dir="rtl">
<tr>
<td>Site Name</td>
<td><input type="text" name="name_site" value="<?=$name_site;?>" ></td>
</tr>
<tr>
<td>Site link</td>
<td><input type="text" name="url_site" value="<?=$url_site;?>"></td>
</tr>
<tr>
<td>Email siten</td>
<td><input type="text" name="email_site" value="<?=$email_site;?>"></td>
</tr>
<tr>
<td>Site description</td>
<td><textarea name="desc_site" rows="4" cols="25" > <?=$desc_site;?> </textarea></td>
</tr>
<tr>
<td>Key words</td>
<td><textarea name="kay_site" rows="4" cols="25" value="<?=$kay_site;?>"> <?=$kay_site;?> </textarea></td>
</tr>
<tr>
<td>Open site</td>
<td>
<select name="oepn_site" >
<?
if ($oepn_site== 1){
echo "<option value='1'>Open to visitor</option>
<option value='2'>Close to visitor</option>";
}
else {
echo "<option value='2'>Close to visitor</option>
<option value='1'>Open to visitor</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td>Close message</td>
<td><textarea name="text_close_site" rows="4" cols="25"> <?=$text_close_site;?> </textarea></td>
</tr>
<tr>
<td colspan="2" class="head"><input type="submit" name="updatesetting" value="save setting"> </td>
</tr>
</table>
</form>
</div>
</body>
</html>
Upvotes: 1
Views: 74
Reputation: 879
change the checking of submission to
if (isset($_POST['updatesetting']))
{
$ns = $_POST['name_site'];
.
.
.
}
Upvotes: 1