Forum Moderators: coopster
The database table has 3 fields:
ID int
Title varchar
duty text
The code:
<?php
require('config.php');
?>
<html>
<head>
<title>Job Smart System</title>
</head>
<body>
<?php
if(!IsSet($titlelist))
{
?>
<form method="post" action=" <?php echo $_SERVER['PHP_SELF'];?> ">
Title:<br />
<input type=text name="Title" size=100><br />
<input type=hidden name="titlelist" value=1>
<input type=submit>
</form>
<?php
}
elseif($stage == 1)
{
/* Open connection to the database */
$conn = mysql_connect(SQL_HOST, SQL_USER, SQL_PASS)
or die('Could not connect to MySQL database. ' . mysql_error());
mysql_select_db(SQL_DB,$conn);
/* Fetch values */
$query = "select id, duty FROM title_duty WHERE Title = '$Title'";
$result = mysql_query($query);
$TitleRow = mysql_fetch_arrays($result);
$TitleID = $LogRow[0];
$Duty = stripslashes($TitleRow[1]);
?>
<form method="post" action=" <?php echo $_SERVER['PHP_SELF'];?> ">
Title:<br />
<inpu type=text name="Title" size=10 value="<?php print($Title);?>"><br />
Essential Function:<br />
<textarea name="Duty" cols=120 rows=10><?php print("Duty");?></textarea><br />
<input type=hidden name="TitleID" value="<?php echo $TitleID;?>">
<input type=hidden name="titlelist" value=2>
<input type=submit>
</form>
<?php
}
elseif($titlelist ==2)
{
/* Open connection to the database */
$conn = mysql_connect(SQL_HOST, SQL_USER, SQL_PASS)
or die('Could not connect to MySQL database. ' . mysql_error());
mysql_select_db(SQL_DB,$conn);
/* Insert values */
$query = "UPDATE title_duty SET Title = '$Title', Duty = 'Duty' WHERE ID = $TitleID";
$result = mysql_query($query);
if($result == 0)
print("We have a problem. \n");
else
print("Edit complete.\n");
?>
<?php
}
?>
</body></html>
I will appreciate any help to resolve this problem.
Thanks.
the first thing to do is figure out where and why the page is blank.
Maybe this thread will give you some tips on how to begin troubleshooting your PHP
PHP Troubleshooting Basics [webmasterworld.com]
isset($titlelist) is always false, because this variable is not defined (assumed false).
To do this
a) write
$titlelist = $_POST["titlelist"];
however isset doesn't do that kind of comparison for variables, so better use
if($titlelist == "1")
{
echo ;
}
elseif($titlelist == "2")
{
echo ;
}
else
{
echo ;
}
Best regards
Michal Cibor