Jump to content

marcus

Members
  • Posts

    1,842
  • Joined

  • Last visited

Posts posted by marcus

  1. [code]
    <?php
    if (!$_SESSION['username'] && !$_POST['login']){ // No session + No Form Login... Display the form...
    echo "
    <form action=test.php method=post name=loginform>
    Username:
    <br>
    <input type=text name=username size=20 class=field1>
    <br>
    Password:
    <br>
    <input type=password name=password size=20 class=field1>
    <br><br>
    <input type=submit value=login class=button1>
    <br><br>
    <a href=register.php>Click Here To Register</a>
    </form>
    ";
    } else if ($_POST['username']){
    //if the form has been submitted... The ifs + elses between this and next comment arnt that important just checking if the login details are correct...

    $username = $_POST['username'];
    $password = $_POST['password'];
    //---
    $result = mysql_query("SELECT * FROM sf_users WHERE username='$username'") or die(mysql_error());
    $user = mysql_fetch_array( $result );
    $num = mysql_num_rows($result);
    if ($num > 0){
    echo "<font color=\"#FF0000\"><b>Unknown username, please try again</b></font>";
    } else {
    $dbusername = $user['username'];
    $dbpassword = $user['password'];
    if ($username == $dbusername && $password == $dbpassword){
    session_register("user");
    $_SESSION['username'] = $username;
    $_SESSION['password'] = $password;
    //-- Rest Of Info On The User
    $_SESSION['member_id'] =  $user['member_id'];
    $_SESSION['email'] =  $user['email'];
    $_SESSION['CL'] =  $user['CL'];
    $_SESSION['banned'] =  $user['banned'];
    //-- Session Variables End
    echo "<font color=\"#FF0000\"><b>Thank you for login in,<br /> You will be redirected to the protected pages in 2 seconds <META HTTP-EQUIV=\"refresh\" CONTENT=\"2; URL=index.php\"></b></font>";
    } else if ($username == $dbusername && $password != $dbpassword){
    echo "<font color=\"#FF0000\"><b>Your Password is incorrect</b></font>";

    } else {
    echo "<font color=\"#FF0000\"><b>Unknown System Error!<br> Please ensure your Cases are correct!</b></font>";
    }
    };


    } elseif ($_SESSION['username']){
    //If we have the session... echo the username has logged in
    //Display member options...
    $uname = $_SESSION['username'];
    echo "<font color='#FFFFFF'><b>$uname... You are already logged in.</b></font>";
    } else {
    //WOOPS somethings gone wrong if i see this...
    echo "<font color='#FFFFFF'><b>Unknown System Error.</b></font>";
    }

    ?>
    [/code]
  2. Ok, well I have made a login script which goes threw to see if the user is confirmed and checks if it exists, but each time I enter in all the date it will keep echoing they are incorrect.

    Here is the code:

    [code]
    <? include('header.php'); ?>
    <?php
    //GRAB DATA FROM THE FORM AND DEFINE VALUES
    $uname = $_POST[username];
    $upass = $_POST[password];
    $action= $_POST[action];
    $timestamp = date("G:i:s");

    //ECHO FORM IF NOTHING IS VALID
    if(empty($uname) && empty($upass) && empty($action)){
    echo "<table border=0 cellspacing=0 cellpadding=0>";
    echo "<form name=".'check'." action=".'login.php'." method=".'post'.">";
    echo "<tr><td colspan=2 align=left><h3>Login</h3></a>";
    echo "<tr><td>Username:<td><input type=text name=username>";
    echo "<tr><td colspan=2>
    <input type=hidden name=action value=check>
    <input type=submit value=".'Login'.">";
    echo "</form>";
    echo "</table";
    };

    if(isset($uname) && empty($upass) && $action == check){
    $check = "SELECT * FROM `users` WHERE username ='$uname'";
    $resch = mysql_query($check) or die(mysql_error());
    $resc1 = mysql_fetch_assoc($resch);
    $confi = $resc1[confirm];
    $userid = $resc1[id];

    //CHECK IF USER ACCOUNT IS CONFIRMED
    if($confi == 0){
    echo "Your account is not confirmed, please check your email, to resend please <a href=".'resend.php?id=$userid'.">";
    }else {
    //PRODUCE SECOND FORM FOR PASSWORD
    echo "<table border=0 cellspacing=0 cellpadding=0>";
    echo "<form name=login action=".'login.php'." method=".'post'.">";
    echo "<tr><td colspan=2 align=left><h3>Login</h3>";
    echo "<tr><td>Username:<td><input type=text name=username value=".$uname." readonly>";
    echo "<tr><td>Password:<td><input type=password name=password>";
    echo "<tr><td colspan=2 valign=left>
    <input type=hidden name=action value=login>
    <input type=submit value=".'Login'.">";
    echo "</form>";
    echo "</table>";
    };
    }else


    //CHECK IF USERNAME AND PASSWORD ARE VALID THREW FORM
    if(empty($uname) || empty($upass)){
    echo "You have not supplied a username and/or a password";
    die();
    };

    //ONLY IF USERNAME AND PASSWORD ARE VALID THE FOLLOWING WITH PROCESS
    if($uname && $upass && $action == login){

    //CHECK IF USERNAME EXISTS
    //DO SQL QUERIES ON UNAME AND UPASS
    $q1 = "SELECT * FROM `users` WHERE username ='$uname' AND pass ='$upass' LIMIT 1";
    $go = mysql_query($q1) or die(mysql_error());
    $q2 = mysql_num_rows($go);
    $q3 = mysql_fetch_assoc($go);
    //IF EXISTS WILL LOG IN
    if($q3 > 0){
    echo "You have now been logged in. If you experience any difficulties navigating the website you may have not enabled or allowed cookies for this website!";
    //SETTING COOKIES FOR A THREE HOUR PERIOD
    setcookie(auth,yes,time()+7200);
    setcookie(id,$id['id'],time()+7200);
    setcookie(username,$id['username'],time()+7200);

    //NEXT WE WILL UPDATE LAST LOGIN
    $q4 = "UPDATE `users` SET lastlogin =$timestamp WHERE username ='$uname'";
    $go2= mysql_query($q4) or die(mysql_error());
    }else {
    echo "Your login details were incorrect, please try again!";
    };
    };
    ?>
    <? include('footer.php'); ?>
    [/code]

    EDIT: Code fixed to log in, but now cookies are not setting.

    [code]

    Warning: Cannot modify header information - headers already sent by (output started at
    /home/neoblob/public_html/cms/header.php:19) in /home/neoblob/public_html/cms/login.php on line 67

    Warning: Cannot modify header information - headers already sent by (output started at
    /home/neoblob/public_html/cms/header.php:19) in /home/neoblob/public_html/cms/login.php on line 68

    Warning: Cannot modify header information - headers already sent by (output started at
    /home/neoblob/public_html/cms/header.php:19) in /home/neoblob/public_html/cms/login.php on line 69


    [/code]
  3. [code]
    <? include('header.php'); ?>
    <?php
    $hash = $_GET['hash'];
    $conf = $_GET['confirm'];
    $exit = $_GET['exit'];



    if($hash == $hash && $conf == yes && $exit == 1){
    $checkconf = "SELECT * FROM `users` WHERE confkey='$hash'";
    $ccres = mysql_query($checkconf);
    $cc2 = mysql_fetch_assoc($ccres);
    $ifconf = $cc2[confirm];

    if($ifconf == 1){
    echo "This account has already been confirmed";
    }

    $checkhash = "SELECT * FROM users WHERE confkey='$hash'";
    $checkhashresult = mysql_query($checkhash);

    if(mysql_num_rows($checkhashresult) > 0){
    $update = "UPDATE users SET confirm = '1' WHERE confkey='$hash'";
    $upres = mysql_query($sql);
    echo "Your account has been confirmed!<br><br>$hash";
    }
    }else{
    echo "You are in the wrong place!";
    }
    ?>
    <? include('footer.php'); ?>
    [/code]

    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/neoblob/public_html/cms/confirm.php on line 12

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/neoblob/public_html/cms/confirm.php on line 22

    The errors happen when the hash, confirm and exit are present.
  4. [tt]Parse error: syntax error, unexpected $end in /home/neoblob/public_html/cms/register.php on line 139[/tt]


    [code]
    <?php include('header.php'); ?>
    <?php
    $action = $_POST[action];
    $act = $_GET[action];
    $username = $_POST[username];
    $bday1 = $_POST[year];
    $bday2 = $_POST[day];
    $bday3 = $_POST[month];
    $userpass = $_POST[password];
    $passconf = $_POST[passconf];
    $email = $_POST[email];
    $emailconf = $_POST[emailconf];
    $userip = $_SERVER[REMOTE_ADDR];
    $ref = $_GET[ref];
    $ref2 = $_POST[ref2];
    $formact = "register.php";
    $formeth = post;

    if($ref){
    $sql = "SELECT id,username FROM users WHERE id=$ref";
    $result = mysql_query($sql);
    $result2 = mysql_fetch_assoc($result);
    $referrer = $result2[username];
    $refid = $result2[id];
    };

    if(!$ref){
    $ref = "0";
    };

    if(!$act){
    echo "Hello! Looks like you want to register for NBCMS. Well just hit register below and get started!!<br><br><a href='?action=register'>Register</a>";
    };

    if($act == register){
    echo "
    <h3>Register</h3>
    <table border=0 cellspacing=0 cellpadding=2>
    <form name=register action=".$formact." method=".$formeth.">
    <input type=hidden name=action value=doreg>
    <tr><td>
    Username:<td colspan=3><input type=text name=username>
    <tr><td>
    Password:<td colspan=3><input type=password name=password>
    <tr><td>
    Confirm:<td colspan=3><input type=password name=passconf>
    <tr><td>
    Email:<td colspan=3><input type=text name=email>
    <tr><td>
    Confirm:<td colspan=3><input type=text name=emailconf>
    <tr><td>
    Birthday:<td>
    <select name=month>
    <option value=January>January
    <option value=February>February
    <option value=March>March
    <option value=April>April
    <option value=May>May
    <option value=June>June
    <option value=July>July
    <option value=August>August
    <option value=September>September
    <option value=October>October
    <option value=November>November
    <option value=December>December
    </select><td>
    <select name=day>";
    ?>
    <?php
    for($i=1; $i<32; $i++){
    echo "<option value=$i>$i</option>";
    };
    ?>
    <?php
    echo "
    </select>
    <td>
    <select name=year>";
    ?>
    <?php
    for($i=1900; $i<1993; $i++){
    echo "<option value=$i>$i</option>";
    };
    ?>
    <?php
    echo"
    </select>
    <tr><td>
    Age:<td>
    <select name=age>";
    ?>
    <?php
    for($i=13; $i<107; $i++){
    echo "<option value=$i>$i</option>";
    };
    ?>
    <?php
    echo "
    </select>";
    if($ref){
    echo "<tr><td>Referrer<td>$referrer<input type=text name=ref2 value=$refid>";
    };
    echo "
    <tr><td colspan=2>
    <input type=submit value=Submit> <input type=reset value=Reset>
    </form>
    </table>";
    };


    if($action == doreg){

    if(!$username || !$email || !$passconf || !$userpass || !$emailconf){
    echo "Please fill in all the missing fields";
    };

    $sqlcun = "SELECT username,email,ip FROM users WHERE username=$username,email=$email,IP=$userip";
    $rescun = mysql_query($sqlcun);
    $numcun = mysql_num_rows($rescun);

    if($userpass != $passconf){
    echo "Your passwords did not match";
    };

    if($email != $emailconf){
    echo "Your emails did not match";
    };

    if($numcun > 0){
    echo "The username, email or IP is already in use!";
    };

    if($username && $email && $passconf && $userpass && $emailconf){
    $addus = "INSERT INTO `users` (`username` , `pass` , `email` , `IP` , `age` , `bday_year` , `bday_month` , `bday_day` , `referred` )VALUES ('$username', '$userpass', '$email', '$userip', '$age', '$bday1', '$bday3', '$bday2', '$ref2');
    $resus = mysql_query($addus);
    };
    };
    ?>
    [/code]

    cant figure it out :/
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.