I am writing a code for a community website where I am making a edit profile feature for registered members. I have the following form:
CODE
Complete the following form to edit your profile:<br /><br />
<form action="index.php?id=13&up=true" method="post" enctype="multipart/form-data">
<table border="0">
<tr>
<td>Avatar: </td>
<td><p align="center"><img src="#" alt="Avatar" width="100" height="100"></p></td>
</tr>
<tr>
<td>Change Avatar: <br>(Leave blank to keep current) Max: 64MB</td>
<td><input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<input type="file" name="userfile" id="userfile">
</td>
</tr>
<tr>
<td>E-Mail: </td>
<td><input type="text" name="EMail" value="<?php echo $EMail; ?>"></td>
</tr>
<tr>
<td>Password: <br>(Leave blank to keep current)</td>
<td><input type="password" name="Password"></td>
</tr>
<tr>
<td>Repeat Password: <br>(Leave blank to keep current)</td>
<td><input type="password" name="Password2"></td>
</tr>
<tr>
<td>Personal Description: </td>
<td><textarea name="Description"><?php echo $Description; ?></textarea></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Update"></td>
</tr>
</table>
</form>
I use a class to connect to the database
CODE
$dat->connect();
Then I have the following code that processes the file upload:
CODE
if($_FILES['userfile']['size'] > 0){
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
if(!get_magic_quotes_gpc()){
$fileName = addslashes($fileName);
}
$query = mysql_query("UPDATE `users` SET `Avatar` = '$content' WHERE `Username` = '$Username' LIMIT 1;") or die("Error");
echo "Avatar Updated, ";
}
That works alright, but when i try to modify the e-mail I find a blank field in the database. Here is the code:
CODE
$email = addslashes($_POST["EMail"]);
echo $email."<br>";
$qy = "UPDATE `users` SET `EMail` = '$email' WHERE `Username` = '$Username' LIMIT 1;";
echo $qy."<br>";
$query = mysql_query($qy) or die("Error");
echo "E-Mail Updated, ";
echo "<br>";
And using made up data the text echoed is:
someone@someone.com
UPDATE `users` SET `EMail` = 'someone@someone.com' WHERE `Username` = 'someone' LIMIT 1l
Email Updated,
But the table looks like this:
------------------------------------------------
| Username | E-Mail |
------------------------------------------------
| someone | |
------------------------------------------------
And before the update it looked like:
---------------------------------------------------
| Username | E-Mail |
----------------------------------------------------
| someone | someone@somewhere.com |
----------------------------------------------------
But I cannot see a cause. Quick help would be appreciated.
This post has been edited by jonesa01: 28 Aug, 2008 - 08:46 AM