4 Replies - 506 Views - Last Post: 27 September 2012 - 06:33 AM Rate Topic: -----

#1 esial  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 23-September 12

captcha verify

Posted 26 September 2012 - 11:51 AM

hi,
i want to use this captcha script.My link

this script has this code below to verify if the answer posted is right.
session_start();
 
if ($_POST['answer']!=$_SESSION['result']) {
	echo "Your answer is wrong! Are you human?";
} else {
	echo "Your answer is correct!";
}



I'm suppose to paste this piece of code in the page that processes the form. MY login script does not do it this way. It processes the form in the same page. So could you help me out in this.

MY login script file that processes the form is shown below:
<?php
error_reporting (E_ERROR | 0);
include 'constants.php';
include 'mail.php';

if(isset($_GET['log_out'])) {
	$Login_Process = new Login_Process;
	$Login_Process->log_out($_SESSION['email_address'], $_SESSION['password']); }

class Login_Process {

	var $cookie_user = CKIEUS;
	var $cookie_pass = CKIEPS;

	function connect_db() {
		$conn_str = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME, $conn_str) or die ('Could not select Database.');
	}

	function query($sql) {

		$this->connect_db();
		$sql = mysql_query($sql);
		$num_rows = mysql_num_rows($sql);
		$result = mysql_fetch_assoc($sql);
			
	return array("num_rows"=>$num_rows,"result"=>$result,"sql"=>$sql);
	
	}

function set_session($email_address, $password) {
	
			$query = $this->query("SELECT * FROM ".DBTBLE." WHERE email_address='$email_address' AND password='$password'");
	
			ini_set("session.gc_maxlifetime", Session_Lifetime); 
			session_start();

			$_SESSION['name']    			= $query['result']['name'];
			$_SESSION['department']     	= $query['result']['department'];
			$_SESSION['email_address'] 		= $query['result']['email_address'];
			$_SESSION['company']      		= $query['result']['company'];
			$_SESSION['mobile']         	= $query['result']['mobile'];
			$_SESSION['user_level']    		= $query['result']['user_level'];
			$_SESSION['password']      		= $query['result']['password'];
	}		
		function Register($post, $process) {

		if(isset($process)) {

		$pass1			= $post['pass1'];
		$pass2			= $post['pass2'];
		$email_address	= $post['email_address'];
		$name			= $post['name'];
		$department		= $post['department'];
		$company		= $post['company'];
		$address		= $post['address'];
		echo $phone;
		$phone			= $post['phoneno'];
		$fax			= $post['fax'];
		$mobile			= $post['mobile'];
		$country		= $post['country'];
		$city			= $post['city'];	
		$postalcode		= $post['postalcode'];
		
		if((!$pass1) || (!$pass2) || (!$email_address) || (!$email_address) || (!$name) || (!$department) || (!$company)) {
		return "Some Fields Are Missing";
		}
		if ($pass1 !== $pass2) {
		return "Passwords do not match";
		}
		$query = $this->query("SELECT email_address FROM ".DBTBLE." WHERE email_address = '$email_address'");
		if($query['num_rows'] > 0){
		return "email_address unavialable, please try a new email_address";
		}
		$query = $this->query("SELECT email_address FROM ".DBTBLE." WHERE email_address = '$email_address'");
		if($query['num_rows'] > 0){
		return "Emails address registered to another account.";
		}
		
		if(Admin_Approvial == true) {
		$status = "pending";
		} else {
		$status = "live";
		}
		
		$this->query("INSERT INTO ".DBTBLE." (name, department, company, email_address, password,phone,mobile,fax,address,country,city,postalcode) VALUES ('$name', '$department', '$company', '$email_address', '".md5($pass1)."','$phone','$mobile','$fax','$address','$country','$city','$postalcode')");
				
		User_Created($email_address, $email);

		if(Admin_Approvial == true) {
		return 'Sign up was sucessful, your account must be reviewed by the administrator before you can login.';
		} else {
		return 'Sign up was sucessful, you may now log in.';
		} 	
	}
	
	} 
		
		



Is This A Good Question/Topic? 0
  • +

Replies To: captcha verify

#2 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3034
  • View blog
  • Posts: 10,582
  • Joined: 08-August 08

Re: captcha verify

Posted 26 September 2012 - 02:24 PM

This is the problem with being a copy/paste programmer. Not only do you have the problem of not knowing if what you're copy/pasting is any good but you also don't know how to apply it.

I suggest you start from scratch and learn the language.
Was This Post Helpful? 3
  • +
  • -

#3 esial  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 23-September 12

Re: captcha verify

Posted 26 September 2012 - 10:58 PM

thank you.

it will be great if you can help.

1
session_start();
2
  
3
if ($_POST['answer']!=$_SESSION['result']) {
4
    echo "Your answer is wrong! Are you human?";
5
}




I tried pasting this in 'function register' which is on line 46.
Was This Post Helpful? 0
  • +
  • -

#4 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3034
  • View blog
  • Posts: 10,582
  • Joined: 08-August 08

Re: captcha verify

Posted 27 September 2012 - 05:35 AM

I am helping. When you take my advice from post 2 we can continue: stop pasting and start writing code. Write no line of code without knowing why you're writing it. If you can't explain what it does then you shouldn't have it in your code.
Was This Post Helpful? 0
  • +
  • -

#5 esial  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 23-September 12

Re: captcha verify

Posted 27 September 2012 - 06:33 AM

I have already WRITTEN MY OWN code for this captcha. It is just one math question, that works well. I just wanted to add some more questions. I can do this myself but i'm supposed to submit this site soon. Anyways, i' ll just stick to what i already did.
Thank you,
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1