ADs

Saturday, February 11, 2012

PHP Logout code

 PHP Logout code


<?
    session_start();
    session_destroy();
    include("include/common.php");
    if ($loggedin){
        if ($logout) {
            $myname = "";
            $myrights = "";
            $myemail = "";
            $loggedin = 0;
            session_register("loggedin");
            session_register("myname");
            session_register("myuid");
            session_register("myrights");
            session_register("myemail");
            $failed = 1;
        }
    }
    header("Location: index.php");
?>

PHP forgot password code

 PHP forgot password code


<?
include("include/common.php");
require_once("include/header.php");



if(isset($_POST[u2]))
{
    $q1 = "SELECT * FROM users WHERE email='$u2'";
    $r1 = mysql_query($q1) or die(mysql_error());
   
    if(mysql_num_rows($r1) == '1')
    {
        $a1 = mysql_fetch_array($r1);

        $to = $a1[email];
        $subject = "Your password";

        $message = "Hello $a1[first_name],\nYour login details are:\n\nUsername: $a1[username]\nPassword: $a1[password]\n\n$sitename\n$siteurl";

       
        mail($to, $subject, $message, "From: $adminemail");

        echo ("Password has been sent to ".$to);
        require_once("include/footer.php");
        exit();
    }
    else
    {
        $error2 = "<center><font face=verdana size=2 color=red>There is no email <b>$_POST[u2]</b> in our database.</font></center>";

    }
}

require_once("include/forgot.php");
require_once("include/footer.php");

?>

PHP edit profile code

 Php edit profile code



 <?
    include("include/common.php");

    if(!$loggedin){
        ob_start();
        header("Location: login.php");
    }
    include("include/header.php");
    include("include/accmenu.php");

    if($submit){
        $sql = "update users set
            password='$spassword',
            first_name='$sfirst_name',
            last_name='$slast_name',
            street='$sstreet',
            city='$scity',
            state='$sstate',
            zip='$szip',
            country='$scountry',
            email='$semail',
            cat='$scat',
            aboutme='$saboutme',
            relocate='$sreloc',
            telephone='$stelephone' WHERE uid='$myuid'";
        mysql_query($sql) or die( mysql_error()."<br>$sql" );
?>
        <h3>Edit your Account Details</h3>
        <form action=account.php method=post>
        <?=$table2?>
        <tr align=center>
            <td colspan=2>Your account details have been saved.</td>
        </tr>
<?
        if ($cpassword != $spassword) {
            echo "<tr align=center><td colspan=2>You will now need to logout <a href=logout.php>here</a> and then login again. Make sure you do not have multiple browser windows open with this site in them.</td></tr>"; 
        }
        echo "</table>";
    }else{
        $this->c=mysql_query("select * from users where uid='$myuid'");
        $this->d=mysql_fetch_object($this->c);
        if(is_object($this->d)) {
            $cusername = $this->d->username;
            $cpassword = $this->d->password;
            $cfirst_name = $this->d->first_name;
            $clast_name = $this->d->last_name;
            $cstreet = $this->d->street;
            $ccity = $this->d->city;
            $czip = $this->d->zip;
            $cstate = $this->d->state;
            $ccountry = $this->d->country;
            $cemail = $this->d->email;
            $ctelephone = $this->d->telephone;
            $clast_paid = $this->d->last_paid;
            $ccat = $this->d->cat;
            $csignup_date = $this->d->signup_date; 
            $caboutme=$this->d->aboutme;
            $creloc=$this->d->relocate;
        }
?>
        <h3>Edit your Account Details</h3>
        <form method=post>
        <?=$table2?>
        <tr align=center>
            <td colspan=2>Edit your account details and then click the submit button below.<p></td>
        </tr>
        <tr>
            <td align=right>Username:</td>
            <td><?=$cusername?></td></tr>
        <tr>
            <td align=right>Password:</td>
            <td><input type=text name=spassword size=35 maxlength=15 value='<?=$cpassword?>'></td></tr>
        <tr>
            <td align=right>First Name:</td>
            <td><input type=text name=sfirst_name size=35 maxlength=20 value='<?=$cfirst_name?>'></td></tr>
        <tr>
            <td align=right>Last Name:</td>
            <td><input type=text name=slast_name size=35 maxlength=30 value='<?=$clast_name?>'></td></tr>
        <tr>
            <td align=right>Street:</td>
            <td><input type=text name=sstreet size=35 maxlength=50 value='<?=$cstreet?>'></td></tr>
        <tr>
            <td align=right>City:</td>
            <td><input type=text name=scity size=35 maxlength=30 value='<?=$ccity?>'></td></tr>
        <tr>
            <td align=right>State/Province:</td>
            <td><input type=text name=sstate size=35 maxlength=30 value='<?=$cstate?>'></td></tr>
        <tr>
            <td align=right>Zip/Postal Code:</td>
            <td><input type=text name=szip size=35 maxlength=10 value='<?=$czip?>'></td></tr>
        <tr>
            <td align=right>Country:</td>
            <td><input type=text name=scountry size=35 maxlength=30 value='<?=$ccountry?>'></td></tr>
        <tr>
            <td align=right>Your Email:</td>
            <td><input type=text name=semail size=35 maxlength=75 value='<?=$cemail?>'></td></tr>
        <tr>
            <td align=right>Telephone:</td>
            <td><input type=text name=stelephone size=35 maxlength=12 value='<?=$ctelephone?>'></td></tr>
        <tr>
            <td align=right>Your Category:</td>
            <td><? buildCatBox("scat",$ccat) ?>       
        <tr>
            <td align=right>Willing To Relocate:</td>
            <td>
                <input type=radio name=sreloc value=1 <?if($creloc){echo "CHECKED";}?>>Yes
                <input type=radio name=sreloc value=0 <?if(!$creloc){echo "CHECKED";}?>>No
            </td>
        <tr>
            <td>Introduce yourself</td>
            <td>
                <textarea name=saboutme cols=50 rows=10><?=$caboutme?></textarea>
            </td>
        </tr>
        <tr>
            <td colspan=2>
                <input type=submit name=submit value='Submit Changes'>
            </td>
        </tr>
        </table>
        </form>
<?
    }
    include("include/footer.php");
?>
<?
    function buildCatBox($name,$sel=""){
?>
        <SELECT NAME="<?=$name?>">
            <option value="">-----
<?
            $qr1 = mysql_query("SELECT * FROM cats ORDER BY name ASC");
            while ($a = mysql_fetch_object($qr1)){
                if($sel == $a->id){
                    echo "<OPTION VALUE=\"{$a->id}\" SELECTED>{$a->name}</OPTION>\n"; 
                }else{
                    echo "<OPTION VALUE=\"{$a->id}\">{$a->name}</OPTION>\n"; 
                }
            }
?>
        </select>
<?
    }
    function getCat($cat){
        $qr1 = mysql_query("SELECT name FROM cats WHERE id='$cat'");
        $a = mysql_fetch_object($qr1);
        return $a->name;
    }
?>

PHP Login page code

<?
    include("include/common.php");

    if( $_POST['username'] && $_POST['password'] ){
        $failed = 1;
        $username = $_POST['username'];
        $password = $_POST['password'];
        $query = "SELECT * FROM users WHERE username='$username' AND password='$password'";
        $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
        if ( ($result) && (mysql_num_rows($result) > 0) ){
            $row = mysql_fetch_object($result);
            $adlogin = $row->username;
            $myname = $row->username;
            $adpassword = $row->password;
            $myuid = $row->uid;
            if ( ($username != $adlogin) || ($password != $adpassword) ){
                $failed = 1;
            }else{
                $failed = 0;
                $loggedin = 1;
                session_register("loggedin");
                session_register("myuid");
                session_register("myname");
            }
        }else{
            $failed = 1;
        }
    }
    if($loggedin){
        ob_start();
        header("Location: account.php");
    }
    include("include/header.php");
?>
<p><font face=arial size=3>
<form action="login.php" method="POST">
<input type="hidden" name="action" value="login"><font face="arial" size="2"><b>Username</b><br>
<input type=text name=username size=30 tabindex="1" maxlength="12"><i>[type in your username]</i></font><br>
<font face="arial" size="2"><br>
<b>Password</b><br>
<input type=password name=password size=30 tabindex="2" maxlength="12"><i>[type in your password]</i></font><br>
<br>
<font face="arial" size="2"><input type="submit" name="" value="Login" tabindex="4" style="background-color:#e5e5e5; color:#000000; font-family:Verdana,Arial; font-weight: bold; font-size: 11px; border-left: 1 solid #a0a0a0; border-top: 1 solid #a0a0a0; border-right: 1 solid #000000; border-bottom: 1 solid #000000; padding: 2 2 2 2; outline: #a0a0a0 solid 2px;">
<br><br>
</font>
<table border="0" cellpadding="0" cellspacing="0" width="178">
<tr height="19">
    <td height="19" valign="top">
        <font face="arial" size="2"><b><a href="password.php"><b>Forgot Your Password?</b></a></b></font>
    </td>
</tr>
<tr height="18">
    <td valign="bottom" height="18">
        <font face="arial" size="2"><b><a href="/join.php"><b>Register New Account!</b></a></b></font>
    </td>
</tr>
</table>
</form>
</font></p>
<?
    include("include/footer.php");
?>

Php Resister code

 Php Resister code

<?
    include("include/common.php");
    include("include/header.php");
?>
<?
#    if(!$submit1)$submit1=1;
    if($submit1 == "1") {
        if($requirepaid) {
?>
            <h3>Signup for a New Account Step 1</h3><form method=post>
            <?=$table2?>
            <tr align=center>
                <td colspan=3>Select a Username. A password will be generated and emailed to you at the end of the signup process.<p></td>
            </tr>
<?            include("include/paidsignupform.php");    ?>
            </table>
            </form> 
<?
        }
        if(!$requirepaid) {
?>
            <h3>Signup for a New Account Step 1</h3><form method=post>
            <?=$table2?>
            <tr align=center>
                <td colspan=2>Fill out the form below. A password will be generated and emailed to you.<p></td>
            </tr>
<?            include("include/nopaidsignupform.php");    ?>
            </table></form>
<?
        }
    }else if($submit1 == "2") {
?>
        <h3>Signup for a New Account</h3>
        <?=$table2?>
        <tr align=center>
            <td colspan=2>Press your browser's 'Back' key and click 'I Agree' to our terms and conditions to continue the signup process.<p></td>
        </tr> 
<?
    }else if($submit2) {
        if(!ereg("^[A-Za-z0-9_]{1,16}$",$susername)) {
            $serror="Invalid username! Use no more than 15 characters and only letters, numbers, and underscores.<br>"; 
        }
        $this->c=@mysql_query("select username from users where username='$susername'");
        $this->d=mysql_fetch_object($this->c);
        if(is_object($this->d)) { $serror="Username is already in use<br>"; }
        $this->c=@mysql_query("select username from pending where username='$susername'");
        $this->d=mysql_fetch_object($this->c);
        if(is_object($this->d)) { $serror="Username is already in use<br>"; }
        echo "<h3>Signup for a New Account Step 3</h3>";
        if (!$serror) {
            $nowtime = time();
            mysql_query("insert into Pending (username,since) values ('$susername','$nowtime')"); 
?>
            <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
            <?="$table2";?>
            <tr>
                <td align=center>
                    Click the button below to signup for our <?=$paypal_sub?> subscription through PayPal. 
                    The first 7 days are free, and you can cancel anytime before the 7 days are up 
                    and be charged nothing.<p>
                    <input type="hidden" name="cmd" value="_xclick-subscriptions">
                    <input type="hidden" name="no_shipping" value="1">
                    <input type="hidden" name="no_note" value="1">
                    <input type="hidden" name="p3" value="1">
                    <input type="hidden" name="t3" value="<?=$paypal_subcode?>">
                    <input type="hidden" name="a1" value="0.00">
                    <input type="hidden" name="src" value="1">
                    <input type="hidden" name="sra" value="1">
                    <input type="hidden" name="business" value="<?="$paypal_email";?>">
                    <input type="hidden" name="item_name" value="<?="$paypal_item";?>">
                    <input type="hidden" name="item_number" value="<?="$paypal_item_number";?>">
                    <input type="hidden" name="a3" value="<?="$paypal_price";?>">
                    <input type="hidden" name="notify_url" value="<?="$paypal_ipn";?>">
                    <input type="hidden" name="currency_code" value="<?="$paypal_currency";?>">
                    <input type="hidden" name="cancel_return" value="<?="$paypal_cancel_return";?>">
                    <input type="hidden" name="return" value="<?="$paypal_return";?>">
                    <input type="hidden" name="os0" value="<?="$susername";?>">
                    <input type="hidden" name="on0" value="Username">
                    <input type="submit" value="Subscribe now">
                </td>
            </tr>
            </table></form>
<? 
        }