Intermediate PHP Configuration is not working properly.
The following script is not working in this server but properly working with freehostia.com server. Please help me. My site is here : http://miworld.uni.cc and this file is here with password protection : http://miworld.uni.cc/admin :
<html>
<head>
<title>
WELCOME ADMIN!
</title>
</head>
<body>
<?php
$dbname = "dbname"; // I have changed the original dbname here
$dbhost = "localhost";
$dbuser = "dbuser"; // I have changed the original dbuser here
$dbpass = "dbpass"; // I have changed the original dbpass here
function connectdb()
{
global $dbname, $dbuser, $dbhost, $dbpass;
$conms = @mysql_connect($dbhost,$dbuser,$dbpass); //connect mysql
if(!$conms) return false;
$condb = @mysql_select_db($dbname);
if(!$condb) return false;
return true;
}
$db = connectdb();
?>
<center>
<h1><u>WELCOME ADMIN!</u></h1><br><br><br>
<?php
$id = "1";
if(!$db)
{
echo "Unable To Connect To Database!";
}
else
{
if($action=="")
{
$message = mysql_fetch_array(mysql_query("SELECT msg, value FROM admin WHERE id='".$id."'"));
echo "<TABLE WIDTH=\"300\" BORDER=\"1\" BORDERCOLOR=\"#00FF00\"><TR><TH>ADMIN MESSAGE</TH></TR><TR><TD align=\"center\">$message[0]</TD></TR></TABLE><br><br><br>";
echo "<b>MESSAGE :</b><br><FORM action=\"index.php\" method=\"get\">";
echo "<input type=\"hidden\" name=\"action\" value=\"save\">";
if($message[1]=="0")
{
$val="Yes";
echo "<small><input type=\"text\" name=\"msg\" title=\"MESSAGE :\" value=\"$message[0]\"></small><br>";
}
elseif($message[1]=="1")
{
$val="No";
echo "<small><input type=\"text\" name=\"msg\" title=\"MESSAGE :\"></small><br>";
}
echo "<input type=\"submit\" value=\"SAVE\">";
echo "</FORM>";
echo "<br><br>";
echo "<b>Show Value : $val</b><br><FORM action=\"index.php\" method=\"get\">";
echo "<input type=\"hidden\" name=\"action\" value=\"value\">";
echo "<select name=\"value\" title=\"Show Value\"><option value=\"0\">Yes</option><option checked=\"checked\" value=\"1\">No</option></select>";
echo "<br><br><input type=\"submit\" value=\"CHANGE\">";
echo "</FORM>";
}
elseif($action=="save")
{
$saved = mysql_query("UPDATE admin SET msg='".$msg."' WHERE id='".$id."'");
if($saved)
{
echo "Your Message Has Been Saved Successfully!";
echo "<br><br><a href=\"index.php\">ADMIN</a>";
}
else
{
echo "Error! Unable To Save";
echo "<br><br><a href=\"index.php\">ADMIN</a>";
}
}
elseif($action=="value")
{
if(($value=="0")||($value=="1"))
{
$changed = mysql_query("UPDATE admin SET value='".$value."' WHERE id='".$id."'");
if($changed)
{
echo "Your Change Has Been Saved Successfully!";
echo "<br><br><a href=\"index.php\">ADMIN</a>";
}
else
{
echo "Error! Unable To Save";
echo "<br><br><a href=\"index.php\">ADMIN</a>";
}
}
else
{
echo "Error! Unable To Save";
echo "<br><br><a href=\"index.php\">ADMIN</a>";
}
}
}
?>
</center>
</body>
</html>
The following script is not working in this server but properly working with freehostia.com server. Please help me. My site is here : http://miworld.uni.cc and this file is here with password protection : http://miworld.uni.cc/admin :
<html>
<head>
<title>
WELCOME ADMIN!
</title>
</head>
<body>
<?php
$dbname = "dbname"; // I have changed the original dbname here
$dbhost = "localhost";
$dbuser = "dbuser"; // I have changed the original dbuser here
$dbpass = "dbpass"; // I have changed the original dbpass here
function connectdb()
{
global $dbname, $dbuser, $dbhost, $dbpass;
$conms = @mysql_connect($dbhost,$dbuser,$dbpass); //connect mysql
if(!$conms) return false;
$condb = @mysql_select_db($dbname);
if(!$condb) return false;
return true;
}
$db = connectdb();
?>
<center>
<h1><u>WELCOME ADMIN!</u></h1><br><br><br>
<?php
$id = "1";
if(!$db)
{
echo "Unable To Connect To Database!";
}
else
{
if($action=="")
{
$message = mysql_fetch_array(mysql_query("SELECT msg, value FROM admin WHERE id='".$id."'"));
echo "<TABLE WIDTH=\"300\" BORDER=\"1\" BORDERCOLOR=\"#00FF00\"><TR><TH>ADMIN MESSAGE</TH></TR><TR><TD align=\"center\">$message[0]</TD></TR></TABLE><br><br><br>";
echo "<b>MESSAGE :</b><br><FORM action=\"index.php\" method=\"get\">";
echo "<input type=\"hidden\" name=\"action\" value=\"save\">";
if($message[1]=="0")
{
$val="Yes";
echo "<small><input type=\"text\" name=\"msg\" title=\"MESSAGE :\" value=\"$message[0]\"></small><br>";
}
elseif($message[1]=="1")
{
$val="No";
echo "<small><input type=\"text\" name=\"msg\" title=\"MESSAGE :\"></small><br>";
}
echo "<input type=\"submit\" value=\"SAVE\">";
echo "</FORM>";
echo "<br><br>";
echo "<b>Show Value : $val</b><br><FORM action=\"index.php\" method=\"get\">";
echo "<input type=\"hidden\" name=\"action\" value=\"value\">";
echo "<select name=\"value\" title=\"Show Value\"><option value=\"0\">Yes</option><option checked=\"checked\" value=\"1\">No</option></select>";
echo "<br><br><input type=\"submit\" value=\"CHANGE\">";
echo "</FORM>";
}
elseif($action=="save")
{
$saved = mysql_query("UPDATE admin SET msg='".$msg."' WHERE id='".$id."'");
if($saved)
{
echo "Your Message Has Been Saved Successfully!";
echo "<br><br><a href=\"index.php\">ADMIN</a>";
}
else
{
echo "Error! Unable To Save";
echo "<br><br><a href=\"index.php\">ADMIN</a>";
}
}
elseif($action=="value")
{
if(($value=="0")||($value=="1"))
{
$changed = mysql_query("UPDATE admin SET value='".$value."' WHERE id='".$id."'");
if($changed)
{
echo "Your Change Has Been Saved Successfully!";
echo "<br><br><a href=\"index.php\">ADMIN</a>";
}
else
{
echo "Error! Unable To Save";
echo "<br><br><a href=\"index.php\">ADMIN</a>";
}
}
else
{
echo "Error! Unable To Save";
echo "<br><br><a href=\"index.php\">ADMIN</a>";
}
}
}
?>
</center>
</body>
</html>
Last edited: