thedigicraft / Atom.CMS

Atom.CMS
56 stars 50 forks source link

user will not update rather adds #142

Open pfize opened 9 years ago

pfize commented 9 years ago

this is my code when I edit the first name and click on submit button it ignores the first condition of the if (i.e. to update user) all it does is the second condition which is to add a user, can someone help me identify the mistake

     if(isset($_POST['submitted'])== 1){

         $first = mysqli_real_escape_string($dbc, $_POST['first']);
         $last = mysqli_real_escape_string($dbc, $_POST['last']);

           if($_POST['password']!=''){
            $password = "password=SHA1('$_POST[password]'),";
           }

          if(isset($_POST['id'])!= ''){
              $action = 'updated';
              $q = "UPDATE users SET first = '$first','last'='$last', $password status=$_POST[status] WHERE id = $_GET[id]";    
            }else {
               $action = 'added';
               $q = "INSERT INTO users (first,last,password,status) VALUES ('$first','$last',SHA1('$_POST[PASSWORD]'),'$_POST[status]')";   

          }

         $r = mysqli_query($dbc, $q);

          if($r){

            $message='<p>User was '.$action.'</p>'; 
           }
            else{

            $message = '<p>user could not be '.$action.' because: '.mysqli_error($dbc);
            $message .= '<p>'.$q.'</p>';
                }       
            }
JasonMate commented 9 years ago

Do you have this bit of code at the bottom of the form?

<input type="hidden" name="submitted" value="1">
<?php if(isset($opened['id'])) { ?>
  <input type="hidden" name="id" value="<?php echo $opened['id']; ?>">
<?php } ?>

On Thu, Jul 23, 2015 at 4:19 AM, pfize notifications@github.com wrote:

this is my code when I edit the first name and click on submit button it ignores the first condition of the if (i.e. to update user) all it does is the second condition which is to add a user, can someone help me identify the mistake

 if(isset($_POST['submitted'])== 1){

     $first = mysqli_real_escape_string($dbc, $_POST['first']);
     $last = mysqli_real_escape_string($dbc, $_POST['last']);

       if($_POST['password']!=''){
        $password = "password=SHA1('$_POST[password]'),";
       }

      if(isset($_POST['id'])!= ''){
          $action = 'updated';
          $q = "UPDATE users SET first = '$first','last'='$last', $password status=$_POST[status] WHERE id = $_GET[id]";
        }else {
           $action = 'added';
           $q = "INSERT INTO users (first,last,password,status) VALUES ('$first','$last',SHA1('$_POST[PASSWORD]'),'$_POST[status]')";

      }

     $r = mysqli_query($dbc, $q);

      if($r){

        $message='<p>User was '.$action.'</p>';
       }
        else{

        $message = '<p>user could not be '.$action.' because: '.mysqli_error($dbc);
        $message .= '<p>'.$q.'</p>';
            }
        }

— Reply to this email directly or view it on GitHub https://github.com/thedigicraft/Atom.CMS/issues/142.

pfize commented 9 years ago

thanks jason I figured that I was missing just that. How can we continue to develop the site as i've reached the last video 112. but need my front-end to look like a modern website,besides also need to create a thread for forum discussion etc. do you have any idea if private classes are given or how to go about this

JasonMate commented 9 years ago

Alan helped me sort out several things I was building on my version. He is a really good teacher. I just used his private training course. http://www.thedigitalcraft.com/private-training

On Sat, Jul 25, 2015 at 11:55 AM, pfize notifications@github.com wrote:

thanks jason I figured that I was missing just that. How can we continue to develop the site as i've reached the last video

  1. but need my front-end to look like a modern website,besides also need to create a thread for forum discussion etc. do you have any idea if private classes are given or how to go about this

— Reply to this email directly or view it on GitHub https://github.com/thedigicraft/Atom.CMS/issues/142#issuecomment-124867163 .