Need help with an activate page

This is a discussion on Need help with an activate page within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Here is my code, it doesn't seem to work, all it does is just redirect the url <?php # ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-03-2006
Anonymous
 
Posts: n/a
Default Need help with an activate page

Here is my code, it doesn't seem to work, all it does is just redirect the
url

<?php # activate.php
// This page activates the user's account.

// Include the configuration file for error management and such.
require_once('./php/config.inc.php');

// Set the page title and include the HTML header.
$page_title = 'Activate Your Account';
include ('../php/header.php');

// Validate $_GET['x'] and $_GET['y'].
if (isset($_GET['x'])) {
$x = (int) $_GET['x'];
} else {
$x = 0;
}
if (isset($_GET['y'])) {
$y = $_GET['y'];
} else {
$y = 0;
}

// If $x and $y aren't correct, redirect the user.
if ( ($x > 0) && (strlen($y) == 32)) {

require_once ('/whereever/mysql_connect.php'); // Connect to the
database.
$query = "UPDATE users SET active= NULL WHERE (user_id=$x AND
active='" . escape_data($y) . "')LIMIT 1";
$result = mysql_query ($query) or trigger_error("Query: $query\n
<br />MySQL Error: " . mysql_error());

// Print a customized message.
if (mysql_affected_rows() == 1) {
echo "<h3>Your account is now active. You may now log in.</h3>";
} else {
echo '<p><font color="red"size="-1">Your account could not
be activated. Please re-check the link or contact the system
administrator.</font></p>';
}
mysql_close();

} else { // Redirect.

// Start defining the URL.
$url = 'http://www.ourvegankitchen.com';

ob_end_clean(); //Delete the buffer.
header("Location: $url");
exit(); //Quit the script.

} // End of main IF-ELSE.

include ('../php/footer.php');
?>


Reply With Quote
  #2 (permalink)  
Old 12-03-2006
Ric
 
Posts: n/a
Default Re: Need help with an activate page

Anonymous schrieb:
> Here is my code, it doesn't seem to work, all it does is just redirect the
> url
>
> <?php # activate.php
> // This page activates the user's account.
>
> // Include the configuration file for error management and such.
> require_once('./php/config.inc.php');
>
> // Set the page title and include the HTML header.
> $page_title = 'Activate Your Account';
> include ('../php/header.php');
>
> // Validate $_GET['x'] and $_GET['y'].
> if (isset($_GET['x'])) {
> $x = (int) $_GET['x'];
> } else {
> $x = 0;
> }
> if (isset($_GET['y'])) {
> $y = $_GET['y'];
> } else {
> $y = 0;
> }
>

How about adding an error_log to see what the vars contain:

error_log("X: $x Y: $y");


> // If $x and $y aren't correct, redirect the user.
> if ( ($x > 0) && (strlen($y) == 32)) {


if you only see the redirect, then either $x is not greater 0 or $y
doesn't contain a value with 32 chars, right.


>
> require_once ('/whereever/mysql_connect.php'); // Connect to the
> database.
> $query = "UPDATE users SET active= NULL WHERE (user_id=$x AND
> active='" . escape_data($y) . "')LIMIT 1";
> $result = mysql_query ($query) or trigger_error("Query: $query\n
> <br />MySQL Error: " . mysql_error());
>
> // Print a customized message.
> if (mysql_affected_rows() == 1) {
> echo "<h3>Your account is now active. You may now log in.</h3>";
> } else {
> echo '<p><font color="red"size="-1">Your account could not
> be activated. Please re-check the link or contact the system
> administrator.</font></p>';
> }
> mysql_close();
>
> } else { // Redirect.
>
> // Start defining the URL.
> $url = 'http://www.ourvegankitchen.com';
>
> ob_end_clean(); //Delete the buffer.
> header("Location: $url");
> exit(); //Quit the script.
>
> } // End of main IF-ELSE.
>
> include ('../php/footer.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

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



All times are GMT +1. The time now is 02:51 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0