ok so m edit page won't edit a users profile, and my errors aren't showing when i load the page???
user back page
<?php
//fetches all of the users from the table
function fetch_users(){
$result = mysql_query("SELECT `user_id` AS `id`, `user_username` AS `username` FROM `users`");
echo mysql_error();
$users = array();
while (($row = mysql_fetch_assoc($result)) !== false){
$users[] = $row;
}
return $users;
}
//fetches profile info for given user
var_dump($user_info);
function fetch_user_info($uid){
$uid = (int)$uid;
$sql = "SELECT
`user_id` AS `id`,
`user_username` AS `username`,
`user_email` AS `email`,
`user_firstname` AS `firstname`,
`user_lastname` AS `lastname`,
`user_institution` AS `institution`,
`user_about institution` AS `aboutinstitution`,
`user_professional title` AS `professionaltitle`,
`user_professional research` AS `professionalresearch`,
`user_professional website` AS `professionalwebsite`,
`user_personal website` AS `personalwebsite`,
`user_personal email` AS `personalemail`,
`user_professional email` AS `professionalemail`,
`user_about your research` AS `aboutyourresearch`,
`user_about yourself` AS `aboutyourself`,
`user_social media` AS `socialmedia`
FROM`users`
WHERE `user_id` = {$uid}";
$result = mysql_query($sql);
echo mysql_error();
$info = mysql_fetch_assoc($result);
$info['avatar'] = (file_exists("{$GLOBALS['path']}/user_avatars/{$info['id']}.jpg")) ? "core.user/user_avatars/{$info['id']}.jpg" : "core.user/user_avatars/defualt.jpg";
return $info;
}
//updates current user portfolio info
function set_profile_info($institution, $aboutinstitution, $professionaltitle, $professionalresearch, $professionalwebsite, $presonalwebsite, $personalemail, $professionalemail, $aboutyourresearch, $aboutyourself, $socialmedia, $avatar){
$institution = mysql_real_escape_string(htmlentities($institution));
$aboutinstitution = mysql_real_escape_string(nl2br(htmlentities($aboutinstitution)));
$professionaltitle = mysql_real_escape_string(htmlentities($professionaltitle));
$professionalresearch = mysql_real_escape_string(htmlentities($professionalresearch));
$professionalwebsite = mysql_real_escape_string(htmlentities($professionalwebsite));
$personalwebsite = mysql_real_escape_string(htmlentities($personalwebsite));
$personalemail = mysql_real_escape_string(htmlentities($personalemail));
$professionalemail = mysql_real_escape_string(htmlentities($professionalemail));
$aboutyourresearch = mysql_real_escape_string(nl2br(htmlentities($aboutyourresearch)));
$aboutyourself = mysql_real_escape_string(nl2br(htmlentities($aboutyourself)));
$socialmedia = mysql_real_escape_string(htmlentities($socialmedia));
if (file_exists($avatar)){
$src_size = getimagesize($avatar);
if ($src_size['mime'] === 'image/jpeg'){
$scr_img = imagecreatefromjpeg($avatar);
}else if ($src_size['mime'] === 'image/png'){
$scr_img = imagecreatefrompng($avatar);
}else if ($src_size['mime'] === 'image/gif'){
$scr_img = imagecreatefromgif($avatar);
}else{
$src_img = false;
}
if ($src_img !== false){
$thumb_width = 200;
if ($scr_size[0] <= $thumb_width){
$thumb = $src_img;
}else{
$new_size[0] = $thumb_width;
$new_size[1] = ($src_size[1] / $src_size[0]) * $thumb_width;
$thumb = imagecreatetruecolor($new_size[0], $new_size[1]);
imagecopyresampled($thumb, $src_img, 0, 0, 0, 0, $new_size[0], $new_size[1], $src_size[0], $src_size[1]);
}
imagejpeg($thumb, "{$GLOBALS['path']}/user_avatars/{$_SESSION['uid']}.jpg");
}
}
$sql = "UPDATE `users` SET
`user_institution` = '{$institution}',
`user_about institution` = '{$aboutinstitution}',
`user_professional title` = '{$professionaltitle}',
`user_professional research` = '{$professionalresearch}',
`user_professional website` = '{$professionalwebsite}',
`user_personal website` = '{$presonalwebsite}',
`user_personal email` = '{$personalemail}',
`user_professional email` = '{$professionalemail}',
`user_about your research` = '{$aboutyourresearch}',
`user_about yourself` = '{$aboutyourself}',
`user_social media` = '{$socialmedia}'
WHERE `user_id` = {$_SESSION['uid']}";
mysql_query($sql);
echo mysql_error();
}
?>
edit page
<?php
include ("core.user/init.inc.user.php");
if (isset($_POST['institution'], $_POST['aboutinstitution'], $_POST['professionaltitle'], $_POST['professionalresearch'], $_POST['professionalwerbsite'], $_POST['personalwebsite'], $_POST['personalemail'], $_POST['professionalemail'], $_POST['abotyourresearch'], $_POST['aboutyourself'], $_POST['socialmedia'])){
$errors = array();
if (filter_var($_POST['personal email'], $_POST['professional email'], FILTER_VALIDATE_EMAIL) === false){
$errors[] = 'The email address you entered is not valid.';
}
if (empty($_FILES['avatar']['tmp_name']) === false){
$file_ext = end(explode('.', $_FILES['avatar']['name']));
if (in_array(strtolower($file_ext), array('jpg', 'jpeg', 'png', 'gif')) === false){
$errors[] = 'your Picture id must be an image';
}
}
if (empty($errors)){
set_profile_info($_POST['institution'], $_POST['aboutinstitution'], $_POST['professionaltitle'], $_POST['professionalresearch'], $_POST['professionalwebsite'], $_POST['personalwebsite'], $_POST['personalemail'], $_POST['professionalemail'], $_POST['abotyourresearch'], $_POST['aboutyourself'], $_POST['socialmedia'], (empty($_FILES['avatar']['tmp_name'])) ? false : $_FILES['avatar']['tmp_name']);
}
$user_info = array(
'institution' => htmlentities($_POST['institution']),
'aboutinstitution' => htmlentities($_POST['aboutinstitution']),
'professionaltitle' => htmlentities($_POST['professionaltitle']),
'professionalresearch' => htmlentities($_POST['professionalresearch']),
'professionalwebsite' => htmlentities($_POST['professionalwebsite']),
'personalwebsite' => htmlentities($_POST['personalwebsite']),
'personalemail' => htmlentities($_POST['personalemail']),
'professionalemail' => htmlentities($_POST['professionalemail']),
'aboutyourresearch' => htmlentities($_POST['aboutyourresearch']),
'aboutyourself' => htmlentities($_POST['aboutyourself']),
'socialmedia' => htmlentities($_POST['socialmedia'])
);
}else{
$user_info = fetch_user_info($_SESSION['uid']);
}
?><?php
if (isset($errors) === false){
echo 'Click update to update your portfolio.';
}else if (empty($errors)){
echo 'Your portfolio has been updated';
}else{
echo '<ul><li>', implode('</li><li>', $errors), '</li></ul>';
}
?><form action="" method="post" nahmme="edit" enctype="multitype/form-data">
<table width="100%" border="0">
<tr>
<td width="23%"><label for='institution'>Institution:</label></td>
<td width="77%"><input type="text" name="Institution" id="institution" value="<?php echo $user_info['institution']; ?>"></td>
</tr>
<tr>
<td><label for='aboutinstituition'>About Instituition:</label></td>
<td><textarea name"aboutinstitution" id="aboutinstitution" rows="15" cols="50"><?php echo strip_tags($user_info['aboutinstitution']); ?></textarea></td>
</tr>
<tr>
<td><label for='professionaltitle'>Professional Title:</label></td>
<td><input type="text" name="professionaltitle" id="professionaltitle" value="<?php echo $user_info['professionaltitle']; ?>"></td>
</tr>
<tr>
<td><label for='professionalresearch'>Professional Research:</label></td>
<td><input type="textarea" name="professionalresearch" id="professionalresearch" value="<?php echo $user_info['professionalresearch']; ?>"></td>
</tr>
<tr>
<td><label for='professionalwebsite:'>Professional Website:</label></td>
<td><input type="text" name="Professional Website" id="" value="<?php echo $user_info['professionalwebsite']; ?>"></td>
</tr>
<tr>
<td width="23%"><label for='personalwebsites'>Personal Websites:</label></td>
<td width="77%"><input type="text" name="personalwebsites" id="personalwebsites" value="<?php echo $user_info['personalwebsite']; ?>"></td>
</tr>
<tr>
<td><label for='personalemail'>personal Email:</label></td>
<td><input type="text" name="personalemail"id="personalemail" value="<?php echo $user_info['personalemail']; ?>"></td>
</tr>
<tr>
<td><label for='professionalemail'>Professional Email:</label></td>
<td><input type="text" name="professionalemail" id="professionalemail" value="<?php echo $user_info['professionalemail']; ?>"></td>
</tr>
<tr>
<td><label for='aboutyourresearch'>About your Research:</label></td>
<td><textarea name"aboutyourresearch" id="aboutyourresearch" rows="15" cols="50"><?php echo strip_tags($user_info['aboutyourresearch']); ?></textarea></td>
</tr>
<tr>
<td><label for='aboutyourself'>Autobiography:</label></td>
<td><textarea name"aboutyourself" id="aboutyourself" rows="15" cols="50"><?php echo strip_tags($user_info['aboutyourself']); ?></textarea></td>
</tr>
<tr>
<td><label for='socialmedia'>Social Networking:</label></td>
<td><input type="text" name="socialmedia" id="socialmedia" value="<?php echo $user_info['socialmedia']; ?>"></td>
</tr>
<tr>
<td><label for='avatar'>Picture Id:</label></td>
<td><input type="file" name="avatar" id="avatar" value=""/></td>
</tr>
</table>
<p><br><br>
<input type="submit" name="submit" value="Update">
</p>
</form>