Jump to content

More troubles with else write


JREAM

Recommended Posts

How come this doesn't write the if($write == false) statement when it fails?

If the submit button is clicked and it doesn't process through, i can't get it to say it didn't go, if I do "else" it all appears on the same page.

 

if ($_POST['submit'] && $pw1 == $pw2 && strlen($pw1) >= 4) {

 

$thefile = 'pw.php'; // Rename to PHP

$fp = fopen($thefile, 'w');

 

// for encoding

$loginwrite = base64_encode($login);

$passwrite = base64_encode($pw1);

// do the write

$write = fwrite($fp, $loginwrite . '|' . $passwrite);

 

if($write == false) {

echo 'Error writing';

 

echo '⋅ Password Must be atleast 4 Characters

<br />⋅ Password must match Verified Password';

}

if($write == true) {

echo '<strong>Password Saved & Changed</strong>';

}

 

fclose($fp);

 

}

Link to comment
https://forums.phpfreaks.com/topic/121162-more-troubles-with-else-write/
Share on other sites

Just a wild suggestion but:

 

if(!fwrite($fp, $loginwrite . '|' . $passwrite)) {
      echo 'Error writing';

   echo '⋅ Password Must be atleast 4 Characters
   
⋅ Password must match Verified Password';
   }
   else {
      echo '<strong>Password Saved & Changed</strong>';
   }

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.