Jump to content

how to display the echo in a different place on my website?


cryptonim

Recommended Posts

hello, I want to display the 

echo ''";

in the right place on my website in changepassword_form.html all messages are written in changepassword.php. how can i move these echo after entering the wrong password or username?

 

changepassword.php

 

<?php
...........
		  //success
		  //change password in db
		  $querychange = mysql_query("UPDATE users SET password='$newpassword' WHERE username='$username'");
		  
		  session_destroy();
		  
		  echo 'Password Has Been Changed Successfully !'; //move these 
		  
		}
		else{
		    echo('new password doesnt match!'); //move these

	}
}
else {
      
           die('old password doesnt match!'); //move these
	   
	}
}
 else
 {

echo "";
include 'changepassword_form.html';
exit();
 }
}
else{
    echo 'you must be logged ';

}
?>


 

move these echos somewhere to my html code how to do these??

I think this might work for you. It may take a little bit to integrate into you existing html but you will get it.

 

If my code doesn't work don't shoot me. The basic idea is to put all of your error messages into a single array and then loop through that array and echo them all at the top of the new page.

<?php
		  //success
		  //change password in db
		  $errors = array();
		  $querychange = mysql_query("UPDATE users SET password='$newpassword' WHERE username='$username'");
		  
		  session_destroy();
		  
		  array_push($errors,'Password Has Been Changed Successfully !'); //move these 
		  
		}
		else{
		    array_push($errors,'new password doesnt match!'); //move these

	}
}
else {
      
           array_push($errors,'old password doesnt match!'); //move these
           
           
           /*
            *  might want to remove this and redirect the user backto the form
            *  instead of killing the page.
            */
	   die('old password doesnt match'); 
	}
}
 else
 {

echo "";
include 'changepassword_form.html';
exit();
 }
}
else{
    echo 'you must be logged ';

}
?>

<html>

<body>
<?php (isset($errors) ??>
<div style="width:100%;bgcolor:red;">
<?php
$i = 1;
foreach ($errors as $error){
echo $i . ' ' . $error . '<br />';
$i++;
});?> 
</div>
<div>
<!-- all of your HTML here -->
</div>
</body>
</html>

 

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.