Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter yadigit

    (@yadigit)

    Thank you. Worked like a charm!

    Forum: Fixing WordPress
    In reply to: $wpdb function.
    Thread Starter yadigit

    (@yadigit)

    Thank you Michael.
    So, in other words, I would take the code that you listed.. and let’s say I take joe1234 am i able to make it a variable? Example ($logged_in_user)?.

    so the code would look like this.,

    $logged_in_user = $current_user->logged_in;
    $result = $wpdb->get_row ("SELECT ID FROM Promo WHERE ID = '$logged_in_user' LIMIT 1");
    
    if (is_null ($row)) {
        $wpdb->insert( 'promocode' , array( 'CODE' => $promocode , 'ID' => $logged_in_user ), array( '%s', '%s' ) );
    
    }

    Would that be the correct code?

    Thread Starter yadigit

    (@yadigit)

    Thank you all for the responses.
    I didn’t see these post until now. But I created a way to send it to the database under a different table.
    Here’s my code below.

    <?php
    // values for answer trial = input answer = answer
    $trial = $_POST["promo"];
    $answer = "membersonly";
    if( $trial == $answer) : ?>
    <?php
    // makes code if correct
    function make_seed()
    {
      list($usec, $sec) = explode(' ', microtime());
      return (float) $sec + ((float) $usec * 225); //how long the code is
    }
    mt_srand(make_seed());
    $promocode = mt_rand(); //promocode is code value
    
    //sets USERID to loggedin user is
    $myname = $current_user->user_login;
    $checkname = $current_user->user_login;
    ?>
    <?php
    
     // Collects data from "promocode" table
     $data = mysql_query("SELECT * FROM promocode")
     or die(mysql_error()); 
    
     // puts the "promocode" info into the $info array
     $info = mysql_fetch_array( $data ); 
    
     // IF command to check if data is there.
    if ($checkname = $info['ID']) { ?>
    <?php echo 'Sorry One Promo Code per-person'; ?>
    <?php }else{ ?>
    <?php echo 'Putting data into database';
    
    $wpdb->insert( 'promocode' , array( 'CODE' => $promocode , 'ID' => $myname ), array( '%s', '%s' ) );
    
    }
     ?>
    
    <?php else : ?>
    
    <form action="https://example.com/promo" method="post">
    Promo Code: <input type="text" name="promo" />
    <input type="submit" />
    </form>
    <?php endif; ?>
    Thread Starter yadigit

    (@yadigit)

    Sorry for placing this in the wrong sub forum.

    Maybe Multi Site is what I should do, but I guess I didn’t do something right?

    Okay, With multi-site.. I expected it how all my sites that I have will be in one easy to navigate admin panel.. so I’ll be able to switch back and forth through sites, (ex: example.com, my.example.com, another.example.com) I already had a fresh installed wordpress in the same database with a different prefex. (eg wp_, wp1_, wp2_)..
    I place
    define('WP_ALLOW_MULTISITE', true);
    in both wordpress config.php..

    I ran the installment for example.com. During the installment it asked if im going to run with a sub-domain, or a nonsub-domain.. I installed with sub-domain. I added my site under the “sites” tab, (my.example.com).. It didn’t link up with each other.
    The main purpose of this is to have one site just for info, and the other site for buying and checking out.

    I guess the bottom line is to allow 2 wordpress sites with the same user login from the same database prefex.

Viewing 4 replies - 1 through 4 (of 4 total)