title: Syntax for if/else statement if insert was successful in a PDO prepared statement
body: <p>I'm trying to switch from mySql statements to PDO prepared statements, but I'm having trouble figuring out the correct syntax for the if/else statements that I have to use if the insert was successful (which were previously <code>if($result) {...}</code>). </p>
  
  <p>I know that  $stmt->execute();  returns true on success or false on failure, but I haven't been able to determine how to set the statement up to act on that. </p>
  
  <p><strong>The new code (PDO prepared statement)</strong> </p>
  
  <pre><code>$gender = $_POST['gender'];  
  if ($gender==="female" ) {
  try {      
     $stmt = $conn-&gt;prepare('INSERT INTO customer_info (fname...) VALUES(:fname...)');
     $stmt-&gt;bindParam(':fname', $_POST['fname'], PDO::PARAM_STR);
     $stmt-&gt;execute();   
      } catch(PDOException $e) {
    echo $e-&gt;getMessage();
  }
  </code></pre>
  
  <p><strong>This is the rest of the original <code>if ($gender==="female")</code> function</strong> </p>
  
  <pre><code>$result = @mysql_query($qry);    
      if($result) {          
        $qry="SELECT * FROM customer_info WHERE user_name='$_POST['user_name']' AND password='$_POST['password']'";
        $result=mysql_query($qry);          
  if($result) {
      if(mysql_num_rows($result) == 1) {
          //user_name Successful
          session_regenerate_id();
          $member = mysql_fetch_assoc($result);
          $_SESSION['SESS_USER_ID'] = $member['user_id'];
          session_write_close();
          header("location: flatter_iframe.html");
          exit();
      }else {        
          header("location: login_failed.html");
          exit();
      }   
  </code></pre>
  
  <p><em>I've deleted most of the variables in order to simplify things (since the code is the same)</em></p>