I am trying to replace mysql fields with this code... But unfortunatly it is not working... I do not know why... Here is the code please help me. Thank you.
<?php
session_start();
if ($_POST['txtName'] != ''){
$host="****";
$username="****";
$password="****";
$db_name="****";
$tbl_name="****";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$userId = $_COOKIE['UserId'];
$userName = $_POST['txtName'];
$sql="UPDATE $tbl_name SET user_name='$userName' WHERE user_id='$userId'";
$result = mysql_query($sql) or die('Query failed. ' . mysql_error());
if ($result==1){
header('Location: profile.php');
}
}
mysql_close();
?>
<html>
<head>
<title>Change Name</title>
</head>
<body>
<form method="post" name="frmChangeName" id="frmChangeName">
<input type="text" name="txtName" id="txtName">
<input type="submit" name="cmdSubmit" value="Change" id="cmdSubmit">
</form>
</body>
</html>