CODE NOT WORKING

Posted on 16th Feb 2014 by admin

Code: [Select]<?php
//include shared codes

include '../lib/common.php';
include '../lib/db.php';
include '../lib/function.php';
include '../lib/User.php';

//construct password request for html

//ob_start();
?>

<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="post">
<P>Enter your user name .A new password wll be sent to the email address on file.</p>

<table>
<tr>
<td><label for="username">Username</label></td>
<td><input type="text" name="username" id="username" value="<?php if (isset($_POST['username'])) echo htmlspecialchars($_POST['username']); ?> "/> </td>

</tr>
<tr>
<td>
</td>
<td><input type="submit" value="Submit" /> </td>
<td><input type="hidden" value="submitted" value="1" /></td>
</tr><tr>
</tr>
</table>
</form>
<?php

//$form = ob_get_clean();

//show the form if this is the first time the page is viewed

if(!isset($_POST['submitted']))
{
$GLOBALS['TEMPLATE']['content'] = $form;
}

//otherwise process incoming data

else
{
//validate usernmae

if(User::validateUsername($_POST['usernmae']))
{
$use= User::getByUsername($_POST['usernmae']);
if(!$user->userId)
{
$GLOBALS['TEMPLATE']['content'] = '<p><strong>Sorry that account doesnot exists.</strong></p>
<p>Please try different user name</p>';
$GLOBALS['TEMPLATE']['content'] .= $form;
}

else
{
//generate a new password

$password= random_text(8);
echo $password;
//send the new password to the email address on record
$message= 'Your new password is: ' . $password;
mail($user->emailAddr, 'New password'. $message);

$GLOBALS['TEMPLATES']['content'] = '<p><strong>A new password has been emailed to you</strong></p>';

//store new password
$user->password=$password;
$user->save();
}
}
//there was invalid data
else

{
$GLOBALS['TEMPLATE']['content'] .= '<p><strong>You didnot provide a valid username</strong></p>';
$GLOBALS['TEMPLATE']['content'] .=$form;
}
}
//dsplay the page
include '../templates/template-page.php';
?>
//hi....
im getting prob with the above code it is not working.I think there is problem with ob_start(); or in $GLOBALS['TEMPLATES']['contents'].hhelp me please

Other forums