Hello there, just joined this forum hoping to find some light to this problem. I am very new at php and trying my best to learn it.
Here is my current problem. I have a form that updates one column in a table named 'title'. But when I submit the form, it leaves it blank. Here is the php.
session_start();
require_once 'database.php';
if(isset($_SESSION['user']))
{
$userid = $_SESSION['user'];
$sql=mysql_query("SELECT * FROM user WHERE username='$userid'");
$data=mysql_fetch_assoc($sql);
if(isset($_GET['action']) && strcasecmp($_GET['action'], "submit") == 0)
{
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc())
{
$_POST['title'] = stripslashes($_POST['title']);
$userid2 = stripslashes($userid);
}
$title = mysql_real_escape_string($_POST['title']);
$userid3 = mysql_real_escape_string($userid);
$update="UPDATE user SET title='$title' WHERE `username`='$userid3'";
$update2=mysql_query($update) or die("Error Updating Account");
if (!$update2)
{
die('Failed');
}else{
echo 'Successful!';
}
And here is the form.
<form name="edit_account" method="post" action="?page=account&action=submit">
<tr><td width="100">Title:</td><td width="200"><input type="text" name="title" value="<?php echo $data['title']; ?>"></td></tr>\
<tr><td width="100"></td><td width="200"><input type="submit" value="Submit Changes"></td></tr>
</table>
</form>
It says successful, and no mysql errors, but it always leaves the column 'title' blank.
Any ideas?