Problem On Profile Page -- Can't edit the user information
Posted: Fri Dec 23, 2011 7:25 am
Hi, i watched BetterPHP's video on Youtube about User Profile. I think it's a very good tutorial. I type all of the PHP code. At last, i want to edit the user information on edit_profile.php but i get a problem. The user information in profile.php does not change.
This is my edit_profile.php code
This is my edit_profile.php code
<?php include('core/init.inc.php'); if (isset($_POST['email'], $_POST['location'], $_POST['about'])) { $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 only contain a-z, 0-9 and spaces.'; } if (empty($errors)){ set_profile_info($_POST['email'], $_POST['about'], $_POST['location']); } $user_info = array( 'email' => htmlentities($_POST['email']), 'about' => htmlentities($_POST['about']), 'location' => htmlentities($_POST['location']), ); }else{ $user_info =fetch_user_info($_SESSION['uid']); } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html"; charset=utf-8"/> <style type="text/css"> form { margin :10px 0px 0px 0px; } form div {float:left; clear:both; margin:0px 0px 4px 0px;} label { float: left; width: 100px;} input[type="text"], textarea{float: left; width:400px; } input[type="submit"] { margin:10px 0px 0px 100px;} </style> <title> Edit Your Profile</title> </head> <body> <div> <?php if (isset($errors) === false){ echo 'Click Update to edit your profile'; }else if (empty($errors)){ echo 'Your profile has been updated.'; }else{ echo '<ul><li>', implode('</li><li>', $errors),'</li> </ul>'; } ?> </div> <form action="" method="post"> <div> <label for="email">Email:</label> <input type="text" name="email" id="email" value="<?php echo $user_info['email']; ?>"/> </div> <div> <label for="location">Location:</label> <input type="text" name="location" id="location" value="<?php echo $user_info['location']; ?>"/> </div> <div> <label for="about">About Me:</label> <textarea name="about" id="about" rows="14" cols="50"/><?php echo strip_tags($user_info['about']); ?></textarea> </div> <div> <input type="submit" value="Update" /> </div> </form> </body> </html>The profile.php code
<?php include('core/init.inc.php'); $user_info = fetch_user_info($_GET['uid']); ?> <html> <head> <title><?php echo $user_info['username']; ?>'s Profile</title> </head> <body> <div> <?php if ($user_info === false){ echo 'That user does not exist.'; }else{ ?> <h1><?php echo $user_info['firstname']; ?> <?php echo $user_info['lastname']; ?></h1> <p>Username: <?php echo $user_info['username']; ?></p> <p>Gender: <?php echo ($user_info['gender']== 1) ? 'Male' : 'Female'; ?></p> <p>Email: <?php echo $user_info['email']; ?></p> <p>Location: <?php echo $user_info['location']; ?></p> <p><?php echo $user_info['about']; ?></p> <?php } ?> </div> </body> </html>Sorry for my bad english; Asian People