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??

Link to comment
Share on other sites

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>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.