Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Quick Question

  1. #1
    Banned
    Join Date
    May 2008
    Posts
    105
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Quick Question

    Hello.

    I need help with some things that i have said at the bottom of the code...

    PHP Code:
    <?php
    require_once('db.php');
    include(
    'functions.php');

        if(isset(
    $_POST['register']))
        {
            if(
    $_POST['username']!='' && $_POST['password']!='' && $_POST['password']==$_POST['password_confirmed'] && $_POST['email']!='' && valid_email($_POST['email'])==TRUE && checkUnique('Username'$_POST['username'])==TRUE && checkUnique('Email'$_POST['email'])==TRUE
            {
            
                
    $query mysql_query("INSERT INTO users (`Username` , `Password`, `Email`, `Random_key`) VALUES ('".mysql_real_escape_string($_POST['username'])."', '".mysql_real_escape_string(md5($_POST['password']))."', '".mysql_real_escape_string($_POST['email'])."', '".random_string('alnum'32)."')") or die(mysql_error());
                
                
    $getUser mysql_query("SELECT ID, Username, Email, Random_key FROM users WHERE Username = '".mysql_real_escape_string($_POST['username'])."'") or die(mysql_error());
        
                if(
    mysql_num_rows($getUser)==1)
                {
    //there's only one MATRIX :PP
                
                    
    $row mysql_fetch_assoc($getUser);
                    
    $headers =     'From: webmaster@ourdomainhere.com' "\r\n" .
                                
    'Reply-To: webmaster@ourdomainhere.com' "\r\n" .
                                
    'X-Mailer: PHP/' phpversion();
                    
    $subject "Activation email from ourdomainhere.com";
                    
    $message "Dear ".$row['Username'].", this is your activation link to join our website. In order to confirm your membership please click on the following link: http://www.ourdomainhere.com/confirm.php?ID=".$row['ID']."&amp;key=".$row['Random_key']." Thank you for joining";
                    if(
    mail($row['Email'], $subject$message$headers))
                    {
    //we show the good guy only in one case and the bad one for the rest.
                        
    $msg 'Account created. Please login to the email you provided during registration and confirm your membership.';
                    }
                    else {
                        
    $error 'I created the account but failed sending the validation email out. Please inform my boss about this cancer of mine';
                    }
                }
                else {
                    
    $error 'You just made possible the old guy (the impossible). Please inform my boss in order to give you the price for this.';
                }
                                
            }
            else {        
                
    $error 'There was an error in your data. Please make sure you filled in all the required data, you provided a valid email address and that the password fields match';    
            }
        }
    ?>
    <?php 
    if(isset($error)){ echo $error;}?>
    <?php 
    if(isset($msg)){ echo $msg;} else {//if we have a mesage we don't need this form again.?>
    <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
        Username: <input type="text" id="username" name="username" size="32" value="<?php if(isset($_POST['username'])){echo $_POST['username'];}?>" /><br />
        Password: <input type="password" id="password" name="password" size="32" value="" /><br />
        Re-password: <input type="password" id="password_confirmed" name="password_confirmed" size="32" value="" /><br />
        Email: <input type="text" id="email" name="email" size="32" value="<?php if(isset($_POST['email'])){echo $_POST['email'];}?>" /><br />
        <input type="submit" name="register" value="register" /><br />
    </form>
    <? ?>
    require_once('db.php');
    include('functions.php');

    So what does the REQUIRE_ONCE('DB.PHP'); mean? What folder does it connect to and what does it do? Is it the Login or Registration.
    The same question with INCLUDE('FUNCTIONS.PHP');

    and do i need them?

    Thanks in advance people.

  • #2
    Regular Coder
    Join Date
    Apr 2006
    Posts
    186
    Thanks
    21
    Thanked 6 Times in 6 Posts
    I think the require_once('db.php'); is your database configurations whereas the include('functions.php'); is your functions... With that you are saying they are both in the same folder as this php page. Functions like valid_email and checkUnique probably come from your functions file? So you pretty much need both of them.

  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    Read the manual pages for both require() and include(). Using the *_once() functions means that it will only be included once, even if you issue the command more than once.

  • #4
    Banned
    Join Date
    May 2008
    Posts
    105
    Thanks
    9
    Thanked 0 Times in 0 Posts
    *resolved*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •