staples27 Posted June 22, 2009 Share Posted June 22, 2009 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 More sharing options...
mattal999 Posted June 22, 2009 Share Posted June 22, 2009 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= Link to comment https://forums.phpfreaks.com/topic/163252-echo-text-from-a-header/#findComment-861309 Share on other sites More sharing options...
staples27 Posted June 22, 2009 Author Share Posted June 22, 2009 just tried it and doesn't seem to work ??? i don't get it because i've used similar methods before on other forms and they work out fine Link to comment https://forums.phpfreaks.com/topic/163252-echo-text-from-a-header/#findComment-861351 Share on other sites More sharing options...
staples27 Posted June 22, 2009 Author Share Posted June 22, 2009 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"); } Link to comment https://forums.phpfreaks.com/topic/163252-echo-text-from-a-header/#findComment-861359 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.