Advertisement
vdp

Untitled

vdp
Jul 31st, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.57 KB | None | 0 0
  1.  
  2. <?php
  3.  
  4. @session_start();
  5. include("../includes/db.php");
  6.  
  7. if(isset($_GET['edit_account']))
  8. {
  9.  
  10.     $customer_email = $_SESSION['customer_email'];
  11.     $get_customer = "select * from customers where customer_email='$customer_email'";
  12.  
  13.     $run_customer=mysqli_query($con,$get_customer);
  14.  
  15.     if($run_customer)
  16.     {
  17.         //CAN DO SOMETHING HERE
  18.     }
  19.    
  20.     $row=mysqli_fetch_array($run_customer);
  21.    
  22.     $id=$row['customer_id'];
  23.  
  24.     $name=$row['customer_name'];
  25.     $email=$row['customer_email'];
  26.  
  27.     $country=$row['customer_country'];
  28.     $city=$row['customer_city'];
  29.     $contact=$row['customer_contact'];
  30.     $address=$row['customer_address'];
  31.     $image=$row['customer_image'];
  32.  
  33. }
  34.  
  35. ?>
  36. <html>
  37. <head></head>
  38. <body>
  39. <form action="" method="post" enctype="multipart/form-data">
  40.  
  41.  
  42.     <table align="center" width="600">
  43.  
  44.  
  45.         <tr>
  46.             <td  align="center">Customer Name: </td>
  47.             <td> <input type="text" class="form-control" name="c_name" value="<?php echo $name;?>"> </td>
  48.         </tr>
  49.  
  50.         <tr>
  51.             <td  align="center">Customer Email: </td>
  52.             <td> <input type="text" class="form-control"  name="c_email" value="<?php echo $email;?>"> </td>
  53.         </tr>
  54.  
  55.        
  56.         <tr>
  57.             <td  align="center">Customer Contact: </td>
  58.             <td> <input type="text" class="form-control"  name="c_contact" value="<?php echo $contact;?>"> </td>
  59.         </tr>
  60.         <tr>
  61.             <td  align="center">Customer country: </td>
  62.             <td>
  63.                 <select class="form-control"  name="c_country:" width="30" disabled>
  64.                     <option value="<?php echo $country; ?>"><?php echo $country;?> </option>
  65.                     <option> Nigeria </option>
  66.                     <option> Ghana </option>
  67.                     <option> United Kingdom </option>
  68.                     <option> United States </option>
  69.                     <option> Japan </option>
  70.                 </select>
  71.  
  72.              </td>
  73.         </tr>
  74.  
  75.         <tr>
  76.             <td  align="center">Customer City: </td>
  77.             <td> <input type="text" class="form-control"  name="c_city" value="<?php echo $city;?>"> </td>
  78.         </tr>
  79.  
  80.         <tr>
  81.             <td  align="center">Customer Address: </td>
  82.             <td> <input type="text" class="form-control"  name="c_address" value="<?php echo $address;?>"> </td>
  83.         </tr>
  84.  
  85.  
  86.         <tr>
  87.             <td  align="center">Customer Image: </td>
  88.             <td> <input type="file" class="form-control-file"  name="c_image" size="60" > <img src="customer_photos/<?php echo $image; ?>" width="60" height="60"> </td>
  89.         </tr>
  90.  
  91.         <tr>
  92.             <td align="center" colspan="8"> <br><input class="btn btn-success" type="submit" name="update_account" value="Update Now"> </td>
  93.         <tr>
  94.     </table>
  95. </form>
  96.  
  97. </body>
  98. </html>
  99.  
  100. <?php
  101.  
  102. //for updating
  103. if(isset($_POST['update_account']))
  104. {
  105.     $update_id=$id;
  106.     $c_name=$_POST['c_name'];
  107.     $c_email=$_POST['c_email'];
  108.    
  109.     $c_city=$_POST['c_city'];
  110.     $c_contact=$_POST['c_contact'];
  111.     $c_address=$_POST['c_address'];
  112.  
  113.  
  114.     $c_image = $_FILES['c_image']['name'];
  115.  
  116.     $c_image_tmp = $_FILES['c_image']['tmp_name'];
  117.  
  118.     move_uploaded_file($c_image_tmp, "customer_photos/$c_image");
  119.  
  120.  
  121.  
  122.     //$update_c="update customers set customer_name='$c_name',customer_email='$c_email,customer_pass='$c_pass',customer_city='$c_city', customer_contact='$c_contact', customer_address='$c_address' WHERE customer_id='$update_id' ";
  123.    
  124.     $update_c="update customers set customer_name='$c_name',customer_email='$c_email',customer_contact='$c_contact',customer_city='$c_city',customer_address='$c_address',customer_image='$c_image' where customer_id ='$id' ";
  125.  
  126.     $run_c=mysqli_query($con,$update_c);
  127.  
  128.     if($run_c)
  129.     {
  130.         echo "<script> alert('your account has been updated')</script>";
  131.     }
  132.     else
  133.     {
  134.         echo "<script> alert('Couldnt update')</script>";
  135.         echo "<script>window.open('my_account.php','_self')</script>";
  136.     }
  137.  
  138. }
  139.  
  140.  
  141. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement