CODE NOT WORKING
Posted on
16th Feb 2014 07:03 pm 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
No comments posted yet
Your Answer:
Login to answer
51
45
Other forums
need help in dynamic select menu in php
hi i have created a dynamic select menu using php. i have a problem in that which is when the user s
login and redirect
hello! can someone help me.. can you give me an idea.. I want to make a login page and redirects it
PHP Upload issue
Hi guys,
I have stumble across an interesting issue with my script and is doing my head in.
Text file to .Dat file Conversion in PHP
Hi All,
Could anybody provide code for Text file to .Dat file Conversion in PHP.
Tha
Code Review - SQL and Insertion Attacks (Warning: Not for Newbs)
Hey guys,
Its been a while, I know. Use to love coming here to answer peoples questions, but
mySQL and PHP search
Hello,
I am trying to code a project and ran into a brick wall with one of my pages. I am pretty
question about n
I was looking at some of the things you could do with php and one of the things I have tried is n.<
How to secure my login data to my database?
Hi there,
It may be a stupid question but I don't know how to secure my login data to my data
Simple PHP/Java Help..
Hi,
I'm trying to build a little program to do with calculating postage. Unfortunately i haven't
Need help/w Page: 1,2,3,4 function!
So I have this code im working on where it's ment to display seperate pages having 20 logs each
I