I have a form which i want submitting to itself, although its not a straight php page it has other conditions involved. Please can you look at my code and give some suggestions?
if($_GET[action] ==add)
{
echo'<tr><td>here you will add a page!</td></tr></table></body></html>';
}
elseif($_GET[action]==editpage && $_POST['submit'])
{
$text = $_POST['text'];
$title = $_POST['title'];
$title_id = $_POST['title_id'];
$sql = "UPDATE pages SET content = '$text', title = '$title' WHERE username = '$_SESSION[user]' AND title = '$title_id';";
mysql_query($sql,$conn);
echo'successfully completed';
}
else { include("nav.php");
?>
<tr>
<td align="center" valign="middle">
<?php nav(); ?>
</td></tr>
<tr><td align="center">
<br>
<form name="" method="post" action="index.php?action=editpage>">
<p>
<?php
$sql = "SELECT * from pages where username = '$_SESSION[user]' AND title='$_GET[id]'";
$result = mysql_query($sql, $conn);
$row = mysql_fetch_assoc($result);
?>
<input type="text" name="title" value="<?php echo $_GET[id]; ?>"><br><br>
<!-- hidden field so that i can determin which title to update -->
<input type="hidden" name="title_id" value="<?php echo $_GET[id]; ?>">
<textarea name="text" cols="40" rows="10"><?php echo $row[content]; ?></textarea>
<br>
<p>
<input type="submit" name="submit" value="submit">
</form>
It is not even showing up "Successfully completed" so i think i either have the url wrong or the if statement wrong?