Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['button'])) {
- $imgFile = $_FILES['img']['name'];
- $tmp_dir = $_FILES['img']['tmp_name'];
- $imgSize = $_FILES['img']['size'];
- if(!empty($imgFile))
- {
- $upload_dir = 'images/'; // upload directory
- $imgExt = strtolower(pathinfo($imgFile,PATHINFO_EXTENSION)); // get image extension
- // valid image extensions
- $valid_extensions = array('jpeg', 'jpg', 'png', 'gif'); // valid extensions
- // rename uploading image
- $coverpic = rand(1000,1000000).".".$imgExt;
- $deat = $upload_dir.'/'.$coverpic;
- // allow valid image file formats
- if(in_array($imgExt, $valid_extensions)){
- // Check file size ‘5MB’
- if($imgSize < 5000000) {
- move_uploaded_file($tmp_dir,$upload_dir.$coverpic);
- }
- else{
- $errMSG = "Sorry, your file is too large.";
- }
- }
- }//empty if end
- else{
- $errMSG = "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
- }
- $dbhost = 'localhost';
- $dbuser = 'root';
- $dbpass = '';
- $conn = mysql_connect($dbhost,$dbuser,$dbpass);
- if(!$conn ) {
- die('Could not connect:'.mysql_error());
- }
- mysql_select_db('jamesthew');
- $u_name = $_POST['name'];
- $usr_name = $_POST['username'];
- $u_pass = $_POST['password'];
- $u_age = $_POST['age'];
- $u_gender = $_POST['gender'];
- $u_email = $_POST['email'];
- $usrid=$_SESSION['uid'];
- if(!empty($imgFile)):
- $sqlt="UPDATE owner SET name = '$u_name',username = '$usr_name',password='$u_pass',image='$deat',age='$u_age',gender='$u_gender',email='$u_email' WHERE id='$usrid'";
- $retval = mysql_query( $sqlt, $conn );
- if(! $retval ) {
- die('Could not update data: ' . mysql_error());
- }
- echo '<div class="alert alert-success">Updated data successfully </div>';
- else:
- $sqlt="UPDATE owner SET name = '$u_name',username = '$usr_name',password='$u_pass',age='$u_age',gender='$u_gender',email='$u_email' WHERE id='$usrid'";
- $retval = mysql_query( $sqlt, $conn );
- if(! $retval ) {
- die('Could not update data: ' . mysql_error());
- }
- echo '<div class="alert alert-success">Updated data successfully </div>';
- //header("Refresh: 2; URL=index.php");
- endif;
- mysql_close($conn);
- }else {
- ?>
- <form class="form-inline" method="POST" action="" enctype="multipart/form-data">
- <div class="form-group">
- <label for="name">Name:</label>
- <input type="text" class="form-control" id="name" name="name" value="<?php echo $uname?>" placeholder="Your Name">
- </div>
- <div class="form-group">
- <label for="username">Username:</label>
- <input type="text" class="form-control" id="username" name="username" value="<?php echo $usrname?>" placeholder="Your Username">
- </div>
- <hr>
- <div class="form-group">
- <label for="password">Password:</label>
- <input type="text" class="form-control" id="password" name="password" value="<?php echo $usrpass?>" placeholder="Your Password">
- </div>
- <div class="form-group">
- <label for="email">Email:</label>
- <input type="email" class="form-control" id="email" name="email" value="<?php echo $usremail?>" placeholder="Your Password">
- </div>
- <hr>
- <div class="form-group">
- <label for="email">Gender:</label>
- <input type="text" class="form-control" id="gender" name="gender" value="<?php echo $usrgender?>" placeholder="Your Password">
- </div>
- <div class="form-group">
- <label for="age">Age:</label>
- <input type="text" class="form-control" id="age" name="age" value="<?php echo $usrage?>" placeholder="Your Password">
- </div>
- <hr>
- <div class="form-group">
- <label for="img">Image:</label>
- <input type="file" accept="image/*" class="form-control" id="img" name="img" placeholder="Your Image">
- </div>
- <p style="color:white;">----------</p>
- <button type="submit" name="button" class="btn btn-warning">Update Details</button>
- </form>
- <?php
- }
- ?>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
- </div>
- </div>
- </div>
Add Comment
Please, Sign In to add comment