Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
  1. #1
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    To handle new users registration on a site of mine, I email them an an activation link, which when loaded in a browser, changes a column named 'activated' value to 'yes'

    The page that is loaded first checks that the user is not registered alreay (e.g. activated is not yes).
    If activated is not yes, then a form with two buttons is displayed. These buttons are to either enable the account (set activated to yes) or leave the account as it is.

    However, I click on the "Yes" button but the form is not submitted.

    Help..!

    PHP Code:
    <body>

    <?php
    include("header.php");

    // this code is to update a row

    if($_POST['submit']=="Yes")
    {
    $name $_POST['user'];
        
    $query "UPDATE users SET activated='yes' WHERE username = '$name'";
        
    $result mysql_query($query) or die(mysql_error());  // 30
        
    if (mysql_affected_rows() > 0
                {
            echo 
    'You are now an official member! <a href=\"login.php\" title=\"Login\">Login</a>.';
            exit;
                } 
        else 
                    { 
            echo 
    'Invalid username.';
                    }}
    if(
    $_POST['submit']=="No")
    {

    ?>
    <script type="text/javascript">
    window.location = "admin.php";
    </script>
    <?php
    }

    include(
    "db.php"); // db conn file

    // now we will check if name is set

    if (isset($_GET['name'])) {
    $name $_GET['name'];
    }
    else if(isset(
    $_POST['name'])) {
    $name $_POST['name'];
    }
    else {
    $name="null";}

    // now we know that $name is set, check it for illegal characters

        // Check for illegal characters
        
    if(!eregi("[a-zA-Z_0-9]",$name)){
        echo 
    "Please do not use weird characters.";
        exit;
        }
        
    $query="SELECT * FROM users where username='$name'";
        
    $result mysql_query($query) or die("Query failed: ".mysql_error());
        
    $numrows mysql_num_rows($result);
        if (
    $numrows == "0") {
            echo 
    "Username does not exisr.<br /><br />";}
        
        else {
        while(
    $row mysql_fetch_array($result))
        {
            
    $activated $row[activated];
        }}

            if (
    $activated == "yes") {
                echo 
    "This account is already activated. <br /><br /><a href=\"login.php\" title=\"Login\">Login</a>.";
                exit;}
            else { 
    ?>

    <div class="msg">
    Do you want to activate this account?<br /><br />

    <forn name="form1" method="post" action="<?php echo $PHP_SELF ?>">
    <input type="submit" name="submit" value="Yes" />
    <br /><br />
    <input type="submit" name="submit" value="No" />
    <input type="hidden" name="user" value="<?php echo $name?>" />

    </form>
    </div>
    <br /><br />

    <?php }
    ?>
    Thanks in advance

  2.  

  3. #2
    Senior Member Eddy Bones's Avatar
    Join Date
    Jan 2004
    Location
    Washington, USA
    Posts
    1,054
    Member #
    4651
    Is the "No" button doing what it's supposed to?

  4. #3
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Its all working now.

    Code:
     <form name="form1" method="get" action="<?php echo $PHP_SELF ?>">
    <input type="submit" name="submit" value="Yes" />
    <br /><br />
    <input type="submit" name="submit" value="No" />
    <input type="hidden" name="name" value="<?php echo $name; ?>" />
    Not entirely sure why it works now but :P


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 06:40 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com