Jump to content

echo text from a header


staples27

Recommended Posts

i'm not sure how best to explain my problem but here goes!

 

basically i have a script that lets the user change their password, the script works fine, i'm just having problem echoing the text from the header into the page, in other words i want the text within the headers to be displayed on the same page..

 

the code is as follows

 

<?php 
session_start();

if (!isset($_SESSION['user']))
{
header("Location: login.php");
}

include ('dbc.php'); 

if ($_POST['Submit']=='Change')
{
$rsPwd = mysql_query("select user_pwd from users where user_name='$_SESSION[user]'") or die(mysql_error());
list ($oldpwd) = mysql_fetch_row($rsPwd);

if ($oldpwd == md5($_POST['oldpwd']))
{
  $newpasswd = md5($_POST['newpwd']);
  
  mysql_query("Update users
  				SET user_pwd = '$newpasswd'
			WHERE user_name = '$_SESSION[user]'
			") or die(mysql_error());

  header("Location: myaccount.php?msg=Password updated...");				
  } else 
  { header("Location: myaccount.php?msg=ERROR: Password does not match..."); }

}

?>
<div class="hsection1">
<div class="title">Change Password</div>
<div class="text">
<p> 
  <?php if (isset($_GET['msgu'])) { echo "<div class=\"msg\"> $_GET[msgu] </div>"; } ?>
   <?php if (isset($_GET['msgd'])) { echo "<div class=\"msg\"> $_GET[msgd] </div>"; } ?>
</p>

<form action="settings.php" method="post" name="form3" id="form3">
  <p>Old Password:
    <input name="oldpwd" type="password" id="oldpwd">
  </p>
  <p>New Password: 
    <input name="newpwd" type="password" id="newpwd">
  </p>
  <p> 
    <input name="Submit" type="submit" id="Submit" value="Change">
  </p>
</form>
</div>
</div>

 

 

if you look under the "div class=text" i've entered the code where i want the text from within these headers to appear:

 

 <?php if (isset($_GET['msgu'])) { echo "<div class=\"msg\"> $_GET[msgu] </div>"; } ?>
   <?php if (isset($_GET['msgd'])) { echo "<div class=\"msg\"> $_GET[msgd] </div>"; } ?>

 

any help would be appreciated, thanks!!

Link to comment
https://forums.phpfreaks.com/topic/163252-echo-text-from-a-header/
Share on other sites

This:

 

<p> 
  <?php if (isset($_GET['msgu'])) { echo "<div class=\"msg\"> $_GET[msgu] </div>"; } ?>
   <?php if (isset($_GET['msgd'])) { echo "<div class=\"msg\"> $_GET[msgd] </div>"; } ?>
</p>

 

Should be:

 

<p> 
  <?php if (isset($_GET['msg'])) { echo "<div class=\"msg\"> $_GET['msg'] </div>"; } ?>
</p>

 

You had msgu and msgd, which don't exist. You redirect to ?msg=

problem solved!

 

just need to change this

 

  header("Location: myaccount.php?msg=Password updated...");            
  } else 
  { header("Location: myaccount.php?msg=ERROR: Password does not match..."); }

 

to this

 

    header("Location: myaccount.php?cp=pwd&msg=Password Updated");	
  }                     
else
  { header("Location: myaccount.php?cp=pwd&msg=Passwords do not match");	 }

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.