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
blank page.... nothing is happening.
I'm new to a lot of this but in the last 24hrs have learned a lot.Installed latest version of mysql... went fine no problems.Installed latest version of php... went fine no problems.did all my
How to ... (FAQs)
... get e-mail notifications
Upload Code Help
Hi everyone I need some help with a bit of code ive been working with for a while. I am completely stumped to why it is now working correctly.Code: <?if(!isset($upload)) {$upload =
Running External Scripts
I am very new to PHP and am not even sure what I'm asking is possible. I have just installed mediaWiki on my site and I'm trying to install some extensions. In order to install the Search
Get ID from Database when Posting with a HTML Form
I have a form I am submitting to a MySql database. Each product has an ID # attached to it that auto_increment.I need to pull the auto incremented ID # for the entry I just posted onto the page so the
square instead of number
HelloI do not know why but this code seems to work fine only in my xampp local insallation but not in the remote server. I just see a black square instead of the number 0000000 when I run this code in
pointer 102 question
I read a book
small inaccuracies
I have this code to convert fractional base 10 into base 2: while($num > 0) { echo "<tr><td>". $num." * 2 =
chat
hello i'm amir
Take info from one coloum and move to another
Hi all,I have this:Code: [Select]$array = "SELECT stock_id FROM stocks WHERE stock_id BETWEEN '1' and '5' ";$res = mysql_query($array);$count = 0;while ($row = mysql_fetch_assoc($res)){ if