http://localhost/html/giveassign2.php?uid=5
when some body clicks in : giveassignment link it goes to that page (with teachers logged in)
i have made following page for assignment...
Code: Select all
<?php
$page_title = 'Give assignment';
if (isset($_POST['submit']))
{
require_once ('../mysql_connect1.php');
if (!empty($_POST['tropic']))
{
$u = escape_data($_POST['tropic']);
} else
{
$u = FALSE;
echo '<p><font color="red">Please enter a URL!</font></p>';
}
if (($_POST['program'] > 0))
{
$p=$_POST['program'];
}
else
{
$p = FALSE;
echo '<p><font color="red">Please select at least one category!</font></p>';
}
if (!empty($_POST['assignment']))
{
$d = escape_data($_POST['assignment']);
}
else
{
$d = '';
}
if ($u && $d)
{
if (isset($_GET['uid']))
{
$tid=$_GET['uid'];
$query = "insert into assignment(teach_id,tropic,program,assignment) VALUES ('$tid','$u','$p','$d')";
$result= mysql_query($query);
if ($result)
{ echo '<p><b>Thank you for your submission!</b></p>';
$_POST = array();
}
else
{
echo '<p>No data returned!</p>';
}
}
else
{
echo '<p>Student not found.</p>';
}
}
}
else
{
echo '<p><font color="red" size="+1">Please enter again.</font></p>';
}
?>
<table border="1" width="100%" bordercolor="#0000FF" bordercolorlight="#0000FF" bordercolordark="#0000FF">
<tr>
<td width="100%">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<p align="center"> <b>Give Assignment</b></p>
<table border="0" width="100%" bgcolor="#EFEFEF">
<tr>
<td width="100%" colspan="3" bgcolor="#00659C">
<p align="center"><b> <font color="#FFFFFF">Please enter data in following fields</font></b></td>
</tr>
<tr>
<td width="41%"><b>Tropic </b></td>
<td width="59%"><input type="text" name="tropic" size="60" maxlength="60" value="<?php if (isset($_POST['tropic'])) echo $_POST['tropic']; ?>" /></td>
</tr>
<tr>
<td width="41%"><b>select Batch </b></td>
<td width="59%"><select name="program"><option >select one</option>
<?php
require_once ('../mysql_connect1.php');
$query = "SELECT batch_id,program from batch";
$result = mysql_query ($query);
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {
echo "<option value=\"{$row['batch_id']}\">{$row['program']}</option>\n";
}
mysql_close();
?>
</select></td>
</tr>
<tr>
<td width="41%"><b>Assignment</b></td>
<td width="59%"><textarea name="assignment" cols="40" rows="5"><?php if (isset($_POST['assignment'])) echo $_POST['assignment']; ?></textarea></td>
</tr>
</table>
<p> </p>
<p><div align="center"><input type="submit" name="submit" value="Register" /></div></p>
</form>
</table>
</form><!-- End of Form -->
<?php // Include the HTML footer.
?>even if there is uid ...and
i want not to enter teachers id manually ...rather take it through other page and enter it implicitly
is this logic correct
Code: Select all
if (isset($_GET['uid']))
{
$tid=$_GET['uid'];
$query = "insert into assignment(teach_id,tropic,program,assignment) VALUES ('$tid','$u','if i remove those uid and all program works
whats the matter....
if i remove any braces or so it gives
prase error in line no 54
any help