how to create capcha in php

Discussion in 'PHP' started by dineshsingh1984, Feb 22, 2011.

  1. #1
    how to create capcha (image verification) in submit form in php................
     
    dineshsingh1984, Feb 22, 2011 IP
  2. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #2
    search first before asking, this is very minor question and already answered here
     
    bartolay13, Feb 22, 2011 IP
  3. dineshsingh1984

    dineshsingh1984 Active Member

    Messages:
    154
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #3
    Ok I'm just try plz solve my another problme....
    I'm create a upload file page where show this error when submit

    I want full permission from ftp but it's not working and server's said i'm give full file permission
    plz give solution........
     

    Attached Files:

    Last edited: Feb 22, 2011
    dineshsingh1984, Feb 22, 2011 IP
  4. tvoodoo

    tvoodoo Active Member

    Messages:
    239
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    53
    #4
    Show us some code then ?
     
    tvoodoo, Feb 22, 2011 IP
  5. dineshsingh1984

    dineshsingh1984 Active Member

    Messages:
    154
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #5
    <?php
    
    include ('db.php');
    include ('image_thumb.php');
    $name	=	$_POST['name'];
    $from	=	$_POST['email']; 
    $file	=	$_POST['fileone'];
    
    if($_FILES['fileone']['size'] > 0)
    		{
    			
    			$sql = 'SELECT max(id) "mid" FROM upload';
    			$rs_mycorner1 = mysql_query($sql) or die("this is selection error");
    			$rs_mycorner2 = mysql_fetch_array($rs_mycorner1);	
    			$mycorner_id = $rs_mycorner2['mid'];
    			$mycorner_id = $mycorner_id + 1;
    			
        		$files=$_FILES['fileone']['name'];
    		
    			$info = pathinfo($files);
    			$file_name =  basename($files,'.'.$info['extension']);
    
    		
    			$filename=stripslashes($files);
    			$extention=getExtenstion($filename);
    			$extention=strtolower($extention);
    			$image_name = $file_name.'_'.$mycorner_id.'.'.$extention;
    			
        	if(move_uploaded_file($_FILES['fileone']['tmp_name'],"../upload/".$image_name))
    		{
    			$sql="insert into upload set name='{$_POST['name']}', email='{$_POST['email']}', file='{$image_name}'";
    	
    	$rs=mysql_query($sql) or die("Additional error");
    	@$rows=mysql_num_rows($rs);
    	
    	echo "one record added sucessfully";
    	}
    		
        	else
    		{
    			echo "An error occurred when we tried to save the uploaded"."<br>";
        	} 
    		if($rows > 0)
    	{
    	
    	$sqlc="select max(id) as idno from upload";
    	$rsc=mysql_query($sqlc) or die("selection error");
    	$rec=mysql_fetch_array($rsc);
    	$files = $rec['idno'];
    	
    	$sqld="select * from upload where id='{$files}'";
    	$rsd=mysql_query($sqld) or die("other selection error");
    	$red=mysql_fetch_array($rsd);
    	$filess=$red['file'];
    	
    	
    	$to="info@rdmemorialphysio.com";
    	
    	$subject="Resume";
    	
    	$message="<b>"."Resume : "."</b>"."http://rdmemorialphysio.com/upload/".$filess;
    		
    	$message = str_replace("\n", "<br>",$message);
    	
    	
    	$mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
    
       // now we'll build the message headers
       $headers = "From: $from\r\n" . 'Reply-To: $from' .
       "MIME-Version: 1.0\r\n" .
          "Content-Type: multipart/mixed;\r\n" .
          " boundary=\"{$mime_boundary}\"";
    	  
       $message = "This is a multi-part message in MIME format.\n\n" .
          "--{$mime_boundary}\n" .
    	  "Content-Type: text/html; charset=utf-8\"\n" .
          "Content-Transfer-Encoding: 7bit\n\n" .
       $message . "\n\n";
       $message.="--{$mime_boundary}--\n";
    ini_set("SMTP","173.244.173.138");
    ini_set("smtp_port","25");
    /*ini_set("sendmail_from","akashcreations@gmail.com");*/
    @$m=mail($to, $subject, $message, $headers);
    	echo $m;
    	}
    	else
    	{
    	echo "no row insert";
    	}
    	/***************************************************/
    	
    	
    	if($m)
    	{?>
    <script language="javascript" type="text/javascript">
    alert("Mail sent successfully.")
    location.replace("upload.php");
    </script>
    <?php exit;
     }
     
     else{ ?>
    <script language="javascript" type="text/javascript">
    alert("There is server error ! Plz Try Again.")
    location.replace("upload.php");
    </script>
    <?php }
    	
    		/***************************************************/
    }
    		?>
    PHP:
     
    dineshsingh1984, Feb 22, 2011 IP
  6. tvoodoo

    tvoodoo Active Member

    Messages:
    239
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    53
    #6
    Try this :
    
    <?php
        include ('db.php');
        include ('image_thumb.php');
        $name = $_POST['name'];
        $from = $_POST['email'];
        $file = $_POST['fileone'];
        
        if(isset($_FILES['fileone']) && $_FILES['fileone']['size'] > 0)
        {
            $sql = 'SELECT max(id) "mid" FROM upload';
            $rs_mycorner1 = mysql_query($sql) or die("this is selection error");
            $rs_mycorner2 = mysql_fetch_array($rs_mycorner1);  
            $mycorner_id = $rs_mycorner2['mid'];
            $mycorner_id = $mycorner_id + 1;
               
            $files=$_FILES['fileone']['name'];
            $info = pathinfo($files);
            $file_name =  basename($files,'.'.$info['extension']);
            
            $filename=stripslashes($files);
            $extention=getExtenstion($filename);
            $extention=strtolower($extention);
            $image_name = $file_name.'_'.$mycorner_id.'.'.$extention;
            
            if(!file_exists("../upload"))
                mkdir("../upload");
            
            if(move_uploaded_file($_FILES['fileone']['tmp_name'],"../upload/".$image_name))
            {
                $rs = mysql_query("insert into upload set name='{$_POST['name']}', email='{$_POST['email']}', file='{$image_name}'") or die("Additional error");
                if(mysql_affected_rows() == 1)
                {
                    echo "one record added sucessfully";
                } else if(mysql_affected_rows() == 0) {
                    $rsc=mysql_query("select max(id) as idno from upload") or die("selection error");
                    $rec=mysql_fetch_array($rsc);
                    $files = $rec['idno'];
                    
                    $sqld="select * from upload where id='{$files}'";
                    $rsd=mysql_query($sqld) or die("other selection error");
                    $red=mysql_fetch_array($rsd);
                    $filess=$red['file'];
                    $to="info@rdmemorialphysio.com";
                    $subject="Resume";
                    $message="<b>"."Resume : "."</b>"."http://rdmemorialphysio.com/upload/".$filess;
                    $message = str_replace("\n", "<br>",$message);
                    
                    $mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
                    // now we'll build the message headers
                    $headers =  "From: $from\r\n" . 'Reply-To: $from' .
                                "MIME-Version: 1.0\r\n" .
                                "Content-Type: multipart/mixed;\r\n" .
                                " boundary=\"{$mime_boundary}\"";
                    
                    $message =  "This is a multi-part message in MIME format.\n\n" .
                                "--{$mime_boundary}\n" .
                                "Content-Type: text/html; charset=utf-8\"\n" .
                                "Content-Transfer-Encoding: 7bit\n\n" .
                    $message . "\n\n";
                    $message.="--{$mime_boundary}--\n";
                    
                    /*
                    ini_set("SMTP","173.244.173.138");
                    ini_set("smtp_port","25");
                    ini_set("sendmail_from","akashcreations@gmail.com");
                    */
                    $m = @mail($to, $subject, $message, $headers);
                    if($m)
                    {
                        echo '  <script language="javascript" type="text/javascript">
                                alert("Mail sent successfully.")
                                location.replace("upload.php");
                                </script>';   
                    } else {
                        echo '  <script language="javascript" type="text/javascript">
                                alert("There is server error ! Plz Try Again.")
                                location.replace("upload.php");
                                </script>';    
                    }
                } else {
                    echo "no row insert";
                }
            } else {
                echo "An error occurred when we tried to save the uploaded"."<br>";
            }
        }
    ?>
    
    PHP:
     
    tvoodoo, Feb 22, 2011 IP
  7. dineshsingh1984

    dineshsingh1984 Active Member

    Messages:
    154
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #7
    without ini_set it's not working because server not supported
    ini_set("SMTP","173.244.173.138");
    ini_set("smtp_port","25");
    currentally this site hosted on machostindia.com
    but i'm try this script on evotech server then this script are work properly.
     
    dineshsingh1984, Feb 23, 2011 IP
  8. tvoodoo

    tvoodoo Active Member

    Messages:
    239
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    53
    #8
    So its ok now ?
     
    tvoodoo, Feb 23, 2011 IP
  9. dineshsingh1984

    dineshsingh1984 Active Member

    Messages:
    154
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #9
    no problem is same actully client site running on machost server and at this server, script is not running

    so plz help..............
     
    dineshsingh1984, Feb 23, 2011 IP
  10. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #10
    Best would be you get and install yourself, I am attaching a captcha package and is easiest one. Download and review the ReadMe file. It requires GD to be available on server.


    About your other problem, it is recommended that you post new topics, so that reader finds relevant material while reaching through search engine.
     

    Attached Files:

    Vooler, Feb 23, 2011 IP
  11. dineshsingh1984

    dineshsingh1984 Active Member

    Messages:
    154
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #11
    thanks 4 suggestion........
     
    dineshsingh1984, Feb 23, 2011 IP
  12. Spradle

    Spradle Peon

    Messages:
    57
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Thank you all for the information
     
    Spradle, Feb 23, 2011 IP