Re: Blog/Sign in/Email Activation/ = Problems
Posted: Tue Apr 24, 2012 10:10 pm
nothing pops up??? :S just stays at click update to edit your portfolio....
no matter what i click it just says that??
user inc
Edit
no matter what i click it just says that??
user inc
<?php error_reporting(E_ALL); //fetches the current logged in users id function fetch_current_user_id($username){ $username = mysql_real_escape_string($username); $sql = "SELECT `user_id` FROM `users` WHERE `user_username` = '{$username}'"; $result = mysql_query($sql); return mysql_result($result, 0); } //check if given username exsists in the database function user_exists($user){ $user = mysql_real_escape_string($user); $total = mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `user_username` = '{$user}'"); echo mysql_error(); return (mysql_result($total, 0) == '1') ? true : false; } //check if the given username and password combinations are valid function valid_credentials($user, $pass){ $user = mysql_real_escape_string($user); $pass = mysql_real_escape_string($pass); $total = mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `user_username` = '{$user}' AND `user_password` = '{$pass}'"); return (mysql_result($total, 0) == '1') ? true : false; } //checks to see is user account is active function is_active($user){ $user = mysql_real_escape_string($user); echo mysql_error(); $sql = "SELECT COUNT(`activations`.`user_id`) FROM `users` INNER JOIN `activations` ON `users`.`user_id` = `activations`.`user_id` WHERE `users`.`user_username` = '{$user}'"; $result = mysql_query($sql); echo mysql_error(); return (mysql_result($result, 0) == '0') ? true : false; } //acctivates the account related to the given activation code function activate_account($aid){ $aid = mysql_real_escape_string($aid); mysql_query("DELETE FROM `activations` WHERE `activation_code` = '{$aid}'"); echo mysql_error(); } //adds a user to the database function add_user($user, $email, $pass, $first, $last){ $user = mysql_real_escape_string(htmlentities($user)); $email = mysql_real_escape_string($email); $pass = sha1($pass); $first = mysql_real_escape_string(htmlentities($first)); $last = mysql_real_escape_string(htmlentities($last)); $charset = array_flip(array_merge(range('a', 'z'), range('A', 'Z'), range('0', '9'))); $aid =implode('', array_rand($charset, 10)); $body = <<<EMAIL Thank you for signing up with knowquest. To activate your account, please click the link below: http://www.jasonmassieportfolio.com/act ... ?aid={$aid} EMAIL; mail($email, 'Your new account at Knowquest.com', $body, 'From: admin@knowquest.com'); mysql_query("INSERT INTO `users` (`user_username`, `user_email`, `user_password`,`user_firstname`,`user_lastname`) VALUES ('{$user}', '{$email}', '{$pass}','{$first}','{$last}')"); echo mysql_error(); $user_id = mysql_insert_id(); mysql_query("INSERT INTO `activations` (`user_id`, `activation_code`) VALUES ({$user_id}, '{$aid}')"); echo mysql_error(); } //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`"); $users = array(); while (($row = mysql_fetch_assoc($result)) !== false){ $users[] = $row; } return $users; } //fetches profile info for given user 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_department` AS `department`, `user_location` AS `location`, `user_speciality` AS `speciality`, `user_key words` AS `keywords`, `user_research centre` AS `researchcentre`, `user_website` AS `website`, `user_articles published pre` AS `articlespublishedpre`, `user_articles published non pre` AS `articlespublishednonpre`, `user_published books` AS `publishedbooks`, `user_social media` AS `socialmedia`, `user_published chapters` AS `publishedchapters`, `user_confidence proceedings` AS `confidenceproceedings`, `user_non acidemic influences` AS `nonacidemicinfluences`, `user_data sets` AS `datasets`, `user_research methodology perferred` AS `researchmethodologyperferred`, `user_researchers cited in your research` AS `researcherscitedinyourresearch`, `user_memberships` AS `memberships`, `user_acidemic influences` AS `acidemicinfluences` 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_avatars/{$info['id']}.jpg" : "core/user_avatars/default.jpg"; return $info; } //updates current user portfolio info function set_profile_info($email, $institution, $department, $location, $speciality, $keywords, $researchcentre, $website, $articlespublishedpre, $articlespublishednonpre, $publishedbooks, $socialmedia, $publishedchapters, $confidenceproceedings, $nonacidemicinfluences, $datasets, $researchmethodologyperferred, $researcherscitedinyourresearch, $memberships, $acidemicinfluences, $avatar){ $email = mysql_real_escape_string(htmlentities($email)); $institution = mysql_real_escape_string(htmlentities($institution)); $department = mysql_real_escape_string(htmlentities($department)); $location = mysql_real_escape_string(htmlentities($location)); $speciality = mysql_real_escape_string(htmlentities($speciality)); $keywords = mysql_real_escape_string(htmlentities($keywords)); $researchcentre = mysql_real_escape_string(htmlentities($researchcentre)); $website = mysql_real_escape_string(htmlentities($website)); $articlespublishedpre = mysql_real_escape_string(htmlentities($articlespublishedpre)); $articlespublishednonpre = mysql_real_escape_string(htmlentities($articlespublishednonpre)); $publishedbooks = mysql_real_escape_string(htmlentities($publishedbooks)); $socialmedia = mysql_real_escape_string(htmlentities($socialmedia)); $publishedchapters = mysql_real_escape_string(htmlentities($publishedchapters)); $confidenceproceedings = mysql_real_escape_string(htmlentities($confidenceproceedings)); $nonacidemicinfluences = mysql_real_escape_string(htmlentities($nonacidemicinfluences)); $datasets = mysql_real_escape_string(htmlentities($datasets)); $researchmethodologyperferred = mysql_real_escape_string(htmlentities($researchmethodologyperferred)); $researcherscitedinyourresearch = mysql_real_escape_string(htmlentities($researcherscitedinyourresearch)); $memberships = mysql_real_escape_string(htmlentities($memberships)); $acidemicinfluences = mysql_real_escape_string(htmlentities($acidemicinfluences)); if (file_exists($avatar)){ $src_size = getimagesize($avatar); if ($src_size['mime'] === 'image/jpeg'){ $src_img = imagecreatefromjpeg($avatar); }else if ($src_size['mime'] === 'image/png'){ $src_img = imagecreatefrompng($avatar); }else if ($src_size['mime'] === 'image/gif'){ $src_img = imagecreatefromgif($avatar); }else{ $src_img = false; } if ($src_img !== false){ $thumb_width = 200; if ($src_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_email` = '{$email}', `user_institution` = '{$institution}', `user_department` = '{$department}', `user_location` = '{$location}', `user_speciality` = '{$speciality}', `user_key words` = '{$keywords}', `user_research centre` = '{$researchcentre}', `user_website` = '{$website}', `user_articles published pre` = '{$articlespublishedpre}', `user_articles published non pre` = '{$articlespublishednonpre}', `user_published books` = '{$publishedbooks}', `user_social media` = '{$socialmedia}', `user_published chapters` = '{$publishedchapters}', `user_confidence proceedings` = '{$confidenceproceedings}', `user_non acidemic influences` = '{$nonacidemicinfluences}', `user_data sets` = '{$datasets}', `user_research methodology perferred` = '{$researchmethodologyperferred}', `user_researchers cited in your research` = '{$researcherscitedinyourresearch}', `user_memberships` = '{$memberships}', `user_acidemic influences` = '{$acidemicinfluences}' WHERE `user_id` = {$_SESSION['uid']}"; mysql_query($sql); echo mysql_error(); } ?>
Edit
<?php include ("core/init.inc.php"); if (isset($_POST['email'], $_POST['institution'], $_POST['department'], $_POST['location'], $_POST['speciality'], $_POST['keywords'], $_POST['researchcentre'], $_POST['website'], $_POST['articlespublishedpre'], $_POST['articlespublishednonpre'], $_POST['publishedbooks'], $_POST['socialmedia'], $_POST['publishedchapters'], $_POST['confidenceproceedings'], $_POST['nonacidemicinfluences'], $_POST['datasets'], $_POST['researchmethodologyperferred'], $_POST['researcherscitedinyourresearch'], $_POST['memberships'], $_POST['acidemicinfluences'])){echo 'TEST'; $errors = array(); if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false){ $errors[] = 'The email address you entered is not valid.'; } if (preg_match('#^[a-z0-9]+$#i', $_POST['location'] === 0)){ $errors = 'Your location must be only numbers (1 - 9) and letters (a - z)'; } 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['email'], $_POST['institution'], $_POST['department'], $_POST['location'], $_POST['speciality'], $_POST['keywords'], $_POST['researchcentre'], $_POST['website'], $_POST['articlespublishedpre'], $_POST['articlespublishednonpre'], $_POST['publishedbooks'], $_POST['socialmedia'], $_POST['publishedchapters'], $_POST['confidenceproceedings'], $_POST['nonacidemicinfluences'], $_POST['datasets'], $_POST['researchmethodologyperferred'], $_POST['researcherscitedinyourresearch'], $_POST['memberships'], $_POST['acidemicinfluences'], (empty($_FILES['avatar']['tmp_name'])) ? false : $_FILES['avatar']['tmp_name']); } $user_info = array( 'email' => htmlentities($_POST['email']), 'institution' => htmlentities($_POST['institution']), 'department' => htmlentities($_POST['department']), 'location' => htmlentities($_POST['location']), 'speciality' => htmlentities($_POST['speciality']), 'keywords' => htmlentities($_POST['keywords']), 'researchcentre' => htmlentities($_POST['researchcentre']), 'website' => htmlentities($_POST['website']), 'articlespublishedpre' => htmlentities($_POST['articlespublishedpre']), 'articlespublishednonpre' => htmlentities($_POST['articlespublishednonpre']), 'publishedbooks' => htmlentities($_POST['publishedbooks']), 'socialmedia' => htmlentities($_POST['socialmedia']), 'publishedchapters' => htmlentities($_POST['publishedchapters']), 'confidenceproceedings' => htmlentities($_POST['confidenceproceedings']), 'nonacidemicinfluences' => htmlentities($_POST['nonacidemicinfluences']), 'datasets' => htmlentities($_POST['datasets']), 'researchmethodologyperferred' => htmlentities($_POST['researchmethodologyperferred']), 'researcherscitedinyourresearch' => htmlentities($_POST['researcherscitedinyourresearch']), 'memberships' => htmlentities($_POST['memberships']), 'acidemicinfluences' => htmlentities($_POST['acidemicinfluences']) ); }else{ $user_info = fetch_user_info($_SESSION['uid']); } ?> <?php if (isset($errors) === false){ echo 'Click update to edit your portfolio.'; }else if (empty($errors)){ echo 'Your portfolio has been updated'; }else{ echo '<ul><li>', implode('</li><li>', $errors), '</li></ul>'; } ?> </h4> <p> <form action="" method="post"> <div> <table width="100%" border="1"> <tr> <td width="38%"><label for="email3"><strong>Email:</strong></label></td> <td width="62%"><input type="text" name="email" id="email" value="<?php echo $user_info['email']; ?>"></td> </tr> <tr> <td><strong> <label for="institution2">Institution:</label> </strong></td> <td><input type="text" name="institution" id="institution" value="<?php echo $user_info['institution']; ?>"></td> </tr> <tr> <td><strong> <label for="department2">Department:</label> </strong></td> <td><input type="text" name="department" id="department" value="<?php echo $user_info['department']; ?>"></td> </tr> <tr> <td><strong> <label for="location2">location:</label> </strong></td> <td><input type="text" name="location" id="location" value="<?php echo $user_info['location']; ?>"></td> </tr> <tr> <td><strong> <label for="speciality2">Speciality:</label> </strong></td> <td><input type="text" name="speciality" id="speciality" value="<?php echo $user_info['speciality']; ?>"></td> </tr> <tr> <td><strong> <label for="keywords2">Key words:</label> </strong></td> <td><input type="text" name="keywords" id="keywords" value="<?php echo $user_info['keywords']; ?>"></td> </tr> <tr> <td><strong> <label for="researchcentre">Research Centre:</label> </strong></td> <td><input type="text" name="researchcentre" id="researchcentre" value="<?php echo $user_info['researchcentre']; ?>"></td> </tr> <tr> <td><strong>Website:</strong></td> <td><input type="text" name="website2" id="website" value="<?php echo $user_info['website']; ?>"></td> </tr> </table> <p> </p> <p> <input type="submit" value="Update"> </p> <p> </p> </div> </form> </p> <p> <form action="" method="post"> <br> <div> <table width="100%" border="1"> <tr> <td width="39%"><strong> <label for="articlespublishedpre2">Articles Published Preffered:</label> </strong></td> <td width="61%"><input type="text" name="articlespublishedpre" id="articlespublishedpre" value="<?php echo $user_info['articlespublishedpre']; ?>"></td> </tr> <tr> <td><strong> <label for="articlespublishednonpre2">Articles Published non Preffered:</label> </strong></td> <td><input type="text" name="articlespublishednonpre" id="articlespublishednonpre" value="<?php echo $user_info['articlespublishednonpre']; ?>"></td> </tr> <tr> <td> <strong> <label for="publishedbooks3">Published Books:</label> </strong></td> <td><input type="text" name="publishedbooks" id="publishedbooks" value="<?php echo $user_info['publishedbooks']; ?>"></td> </tr> <tr> <td><strong> <label for="socialmedia2">Social Media:</label> </strong></td> <td><input type="text" name="socialmedia" id="socialmedia" value="<?php echo $user_info['socialmedia']; ?>"></td> </tr> <tr> <td><strong> <label for="publishedchapters2">Published Chapters:</label> </strong></td> <td><input type="text" name="publishedchapters" id="publishedchapters" value="<?php echo $user_info['publishedchapters']; ?>"></td> </tr> <tr> <td><strong> <label for="confidenceproceedings2">Confidence Proceedings:</label> </strong></td> <td><input type="text" name="confidenceproceedings" id="confidenceproceedings" value="<?php echo $user_info['confidenceproceedings']; ?>"></td> </tr> <tr> <td><strong> <label for="nonacidemicinfluences2">Non Acidemic Influences:</label> </strong></td> <td><input type="text" name="nonacidemicinfluences" id="nonacidemicinfluences" value="<?php echo $user_info['nonacidemicinfluences']; ?>"></td> </tr> <tr> <td><strong> <label for="datasets2">data sets:</label> </strong></td> <td><input type="text" name="datasets" id="datasets" value="<?php echo $user_info['datasets']; ?>"></td> </tr> <tr> <td> <strong> <label for='researchmethodologyperferred2'>Research Methodology Perferred:</label> </strong></td> <td><input type="text" name="website" id="researchmethodologyperferred" value="<?php echo $user_info['researchmethodologyperferred']; ?>"></td> </tr> <tr> <td> <strong> <label for="researcherscitedinyourresearch2">Researchers Cited in Your Research:</label> </strong></td> <td><input type="text" name="researcherscitedinyourresearch" id="researcherscitedinyourresearch" value="<?php echo $user_info['researcherscitedinyourresearch']; ?>"></td> </tr> <tr> <td><strong> <label for="memberships2">Memberships:</label> </strong></td> <td><input type="text" name="memberships" id="memberships" value="<?php echo $user_info['memberships']; ?>"></td> </tr> <tr> <td><strong> <label for="acidemicinfluences2">Acidemic Influences:</label> </strong></td> <td><input type="text" name="acidemicinfluences" id="acidemicinfluences" value="<?php echo $user_info['acidemicinfluences']; ?>"></td> </tr> </table> <p> </p> <p> <input type="submit" value="Update"> </p> <p> </p> </div> </form> </p> <p> <form action="" method="post" enctype="multipart/form-data"> <div></div> <br> <div> <table width="100%" border="1"> <tr> <td width="39%"><label for="avatar2"><strong>Photo Identaficaction:</strong></label></td> <td width="61%"><input type="file" name="avatar" id="avatar" value="<?php echo $user_info['avatar']; ?>"></td> </tr> </table> <p> </p> <p> <input type="submit" value="Update"> </p> <p> </p> </div> </form> </p> </div>