Jump to content

Bounty

Members
  • Posts

    78
  • Joined

  • Last visited

    Never

Posts posted by Bounty

  1. Well i'm using xampp localhost server shouldn't i be administrator? :P

    I found a way to activate SMTP on google but it won't stop error :S

     

    As for do_login.php i forgot to copy you the error..

    Notice: Undefined variable: _SESSION in C:\xampp\htdocs\login\do_login.php on line 5

     

    Warning: mysql_query() expects parameter 1 to be string, resource given in C:\xampp\htdocs\login\do_login.php on line 19

    No souch user!

  2. Hello everyone,i was trying to make a register/login pages on my own and well i got stuck..and my good friend google couldn't help me :S

     

    So well i came to ask proffesionals :)

     

    Okay here is it:

    First thing i don't get is about email activation that i wanted to use on my register page...

    I got do_reg.php file that looks like this:

    <?php
    
    include 'connection.php';
    
    //grab data from form
    $name = $_POST['username'];
    $pass = $_POST['password'];
    $pass_conf = $_POST['pass_conf'];
    $email = $_POST['email'];
    $ip = $_POST['ip'];
    
    //if else
    if($name == false || $pass == false || $pass_conf == false || $email == false){
    echo "Please fill in all the required fields.";
    };
    if($pass != $pass_conf){ 
       echo "Blah..Passwords do not match."; 
    }else{
    //generate random code
    $code = rand(11111111,99999999);
    //send email
    $subject = "Activate your account";
    $headers = "From: admin@mysite.com";
    $body = "Hello $name,\n\nYou registered and need to activate your account. Click the link below or paste it into the URL bar of your browser\n\n http://localhot/login/activate.php?code=$code\n\nThanks!";
    if (!mail($email,$subject,$body,$headers))
    	echo "Error,what a shame!";
    	else {
    	$sql = mysql_query("INSERT INTO users (username,password,email,code,active,ip)
    				VALUES('$name','$pass','$email','$code',0,'$ip')") or die(mysql_error());
    	$result = mysql_query($sql);
    	echo "Thank you for registering! But your account is not still active :'( Please check your email ($email) for activation code! ";
    	}
    };
    ?>

    I went through thousands of erros and still couldn't make it work,i am using xampp localhost server for now and maybe that is the reason it wont work even if i tried to activate SMTP and that stuff in php.ini conf file (as my friend google told me)..

    So this is one of the errors:

    Warning: mail() [function.mail]: SMTP server response: 550 relaying denied in C:\xampp\htdocs\login\do_reg.php on line 25

    Error,what a shame!

     

    Now the next thing i couldn't understand is where is the error inside this script... (do_login.php)

    <?php
    
    include 'connection.php';
    
    $session_username = $_SESSION['username'];
    
    if($_POST['login']) 
    {
    	//get form data
    	$username = $_POST['username'];
    	$password = $_POST['password'];
    	}
    if(!$username||!$password)
    		echo "Username and password missing!";
    else {
    	//login
    	$login = mysql_query("SELECT * FROM users WHERE username='$username'");
    	}
    	if (mysql_query($login)==0)
    		echo "No souch user!";
    	else 
    	{
    	while ($login_row = mysql_fetch_assoc($login)) 
    	{
    	$password_db = $login_row['password'];
    	$password = md5($password);
    
    if ($password!=$password_db)
    	echo "Incorect password!";
    else 
    {
    //check if active
    $active = $login_row['active'];
    $email = $login_row['email'];
    
    if ($active==0)
    	echo "You haven't activated your account, please check your email ($email) for activation!";
    else 
    {
    	$_SESSION['username']=$username; //assign session
    	header("Location: index.php");//refresh
    }
    }
    }
       }
    ?>

     

    Thank you for your spent time and help..:)

  3. Nevermind about last post...i got it :P

    Just tell me how to do this:

     

    // in english page

    if($_COOKIE['TestCookie'] == 'Serbian') {

    header("location:serbian/index.php");

    } else {

    // english page here

    }

    Should i insert whole page html instead of comment?

  4. Can't something like this be done?

    <?php
    if($_COOKIE['TestCookie'] == 'srb') {
    header("location:index2.php");
    } else {
    $Month = 2592000 + time(); 
    $value = 'eng';
    setcookie("lang", $value, $Month);
    }
    //and keep with page
    ?>

     

    And can you write me a js code for image-link-cookie set?

    Please?

    Thanks :)

  5. I get it...just 1 thing..

    // in english page

    if($_COOKIE['TestCookie'] == 'Serbian') {

    header("location:serbian/index.php");

    } else {

    // english page here

    }

    Where is "//english page here" couldn't there be something like "do nothing and keep loading the page"?

    Or you think to insert whole <html></html> code inside of it?

  6. I only need 2 pages original eng and sidepage srp. So i wanted to add a "checker" to eng page (if cookie is "srp" redirect if not continue) and two buttons that will change the value of cookie (1 and 0)...

     

    I don't understand this linking "?lang=english"...

  7. The thing is that i got 2 pages.. one written in English and one on Serbian...so i want if person press a image-link that leads to Serbian page it should create cookie so every time after a person loads my site it gets redirected to serbian page...and if clicked back to English image-link the cookie gets deleted and it should run as every else site...

    I hope you understood what i want to do ://

     

    Thanks for helping..

  8. This is my original topic. Well after wildteen88 posted that i should use JS to make cookies by clicking a link. I used google to find a tutorial on how to do that but my tries wasn't successful...

    So could you help me build a image button+setting cookie+switching to page2....?

     

    Thanks :)

  9. Ok here are my 3 php pages:

     

    set.php

    <?php
    $Month = 2592000 + time(); 
    $value = '1';
    setcookie("cs_hpage", $value, $Month);
    ?>
    

     

    get.php

    <?php
      if (isset($_COOKIE["cs_hpage"])) {
        $cookie = $_COOKIE["cs_hpage"];
        print("Received a cookie: ".$cookie."\n");
      } else {
        print("Fail!.\n");
      }
    ?>
    

     

    clear.php

    <?php 
    setcookie ("cs_hpage", "", time()-60000); 
    ?> 
    

     

    It all works like charm but i dont know how to set

    if $cookie == 1

    echo "Cookie here!"

    and if other then 1

    echo "Fail!"

     

    All i managed to do is as you can see to echo the cookie :/

     

    And question no.2:

    How can i set a cookie through a button?? (Like when pressed set cookie to value "1")

     

    Thanks..

×
×
  • 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.