Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9
This is the forum to discuss the Wrox book PHP and MySQL: Create-Modify-Reuse by Timothy Boronczyk, Martin E. Psinas; ISBN: 9780470192429
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 8th, 2012, 06:51 PM
Registered User
Points: 13, Level: 1
Points: 13, Level: 1 Points: 13, Level: 1 Points: 13, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default chapter1: (register.php)

i have trouble for coding the file register for sending the activation email i do'nt see the registration form in my webpage

the url of my link is http://www.vandenhovennokah.be/wrox_...s/register.php

[/code]
<?php
// include shared code
include '../lib/common.php';
include '../lib/db.php';
include '../lib/functions.php';
include '../lib/User.php';

// start or continue session so the CAPTCHA text stored in $_SESSION is
// accessible
session_start();
header('Cache-control: private');

// prepare the registration form's HTML
ob_start();
?>
<form method="post"
action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>">
<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><label for="password1">Password</label></td>
<td><input type="password" name="password1" id="password1"
value=""/></td>
</tr><tr>
<td><label for="password2">Password Again</label></td>
<td><input type="password" name="password2" id="password2"
value=""/></td>
</tr><tr>
<td><label for="email">Email Address</label></td>
<td><input type="text" name="email" id="email"
value="<?php if (isset($_POST['email']))
echo htmlspecialchars($_POST['email']); ?>"/></td>
</tr><tr>
<td><label for="captcha">Verify</label></td>
<td>Enter text seen in this image<br/ >
<img src="img/captcha.php?nocache=<?php echo time(); ?>" alt=""/><br />
<input type="text" name="captcha" id="captcha"/></td>
</tr><tr>
<td> </td>
<td><input type="submit" value="Sign Up"/></td>
<td><input type="hidden" name="submitted" value="1"/></td>
</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 password
$password1 = (isset($_POST['password1'])) ? $_POST['password1'] : '';
$password2 = (isset($_POST['password2'])) ? $_POST['password2'] : '';
$password = ($password1 && $password1 == $password2) ?
sha1($password1) : '';

// validate CAPTCHA
$captcha = (isset($_POST['captcha']) &&
strtoupper($_POST['captcha']) == $_SESSION['captcha']);

// add the record if all input validates
if ($password &&
$captcha &&
User::validateUsername($_POST['username']) &&
User::validateEmailAddr($_POST['email']))
{
// make sure the user doesn't already exist
$user = User::getByUsername($_POST['username']);
if ($user->userId)
{
$GLOBALS['TEMPLATE']['content'] = '<p><strong>Sorry, that ' .
'account already exists.</strong></p> <p>Please try a ' .
'different username.</p>';
$GLOBALS['TEMPLATE']['content'] .= $form;
}
else
{
//create an inactive user record
$user = new User();
$user-> username = $_POST['username'];
$user-> password = $password;
$user-> emailAddr = $_POST['email'];
$token = $user-> setInactive();


$message = 'Thank you for signing up for an account! Before you '.
' can login you need to verify your account. You can do so ' .
'by visiting http://www.example.com/verify.php?uid=' .
$user-> userId . ' & token=' . $token . '.';
if (@mail($user-> emailAddr, 'Activate your new account', $message))
{
$GLOBALS['TEMPLATE']['content'] = ' <p><strong> Thank you for ' .
'registering. </strong></p><p> You will be receiving an ' .
'email shortly with instructions on activating your ' .
'account. </p> ';
}
else
{
$GLOBALS['TEMPLATE']['content'] = ' <p><strong> There was an ' .
'error sending you the activation link. </strong></p> ' .
' <p> Please contact the site administrator at <a href="' .
'mailto:admin@example.com"> admin@example.com </a> for ' .
'assistance. </p> ';
}
}
}

}
?>

[/code]
Reply With Quote
  #2 (permalink)  
Old December 10th, 2012, 07:04 PM
Authorized User
Points: 374, Level: 6
Points: 374, Level: 6 Points: 374, Level: 6 Points: 374, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2009
Location: San Jose, Californina
Posts: 77
Thanks: 4
Thanked 6 Times in 6 Posts
Default

Hi nokah1988,

The register.php file you posted here is
missing the last line.
Code:
include '../templates/template-page.php';
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
CH 14 register.php not working dlhicksjr BOOK: Beginning PHP 5.3 2 July 31st, 2011 01:36 PM
ch_01 - register.php rod.jeff BOOK: PHP and MySQL: Create-Modify-Reuse ISBN: 978-0-470-19242-9 1 November 3rd, 2009 01:10 PM
chapter 12 modified register.php problem GOUR CHANDRA PAUL BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 June 6th, 2006 03:41 PM
PHP register globals question Charagrin BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 February 6th, 2006 05:02 PM
register.php: clearing html form fields lamada BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 October 26th, 2004 01:25 PM



All times are GMT -4. The time now is 02:06 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.