Results 1 to 4 of 4

Thread: [RESOLVED] captcha Problem

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2004
    Posts
    1,202

    Resolved [RESOLVED] captcha Problem

    Hello,

    I'm having problems with my captcha when i type the data in to my form everything works but when it tells the error message the footer disappears at the bottom can anyone help me please this is the code.

    Name:  register.php image.PNG
Views: 1803
Size:  17.1 KBName:  error code.PNG
Views: 381
Size:  126.3 KB

    PHP Code:
    <?php $title "MBAPPZ.com - Register"?>

    <?php require("styles/top.php"); ?>

            <div id='left'>
            
                    <?php
        
        session_start
    ();
        
        
    $form "<form action='register.php' method='post' enctype='multipart/form-data'>
        <table cellspacing='10px'>
            <tr>
            <td></td>
            <td>Complete the form below <font color='Red'>*</font> are required</td>
        </tr>
        <tr>
            <td>First Name:</td>
            <td><input type='text' name='firstname' class='textbox' size='35'><font color='Red'>*</font></td>
        </tr>
        <tr>
            <td>Last Name:</td>
            <td><input type='text' name='lastname' class='textbox' size='35'><font color='Red'>*</font></td>
        </tr>
        <tr>
            <td>Username:</td>
            <td><input type='text' name='username' class='textbox' size='35'><font color='Red'>*</font></td>
        </tr>
        <tr>
            <td>Email::</td>
            <td><input type='text' name='email' class='textbox' size='35'><font color='Red'>*</font></td>
        </tr>
        <tr>
            <td>Password:</td>
            <td><input type='password' name='password' class='textbox' size='35'><font color='Red'>*</font></td>
        </tr>
        <tr>
            <td>Confirm Password:</td>
            <td><input type='password' name='repassword' class='textbox' size='35'><font color='Red'>*</font></td>
        </tr>
        <tr>
            <td>Avatar:</td>
            <td><input type='file' name='avatar'></td>
        </tr>
        <tr>
            <td>Website Address:</td>
            <td><input type='text' name='website' class='textbox' size='35'></td>
        </tr>
        <tr>
            <td>Youtube Username:</td>
            <td><input type='text' name='youtube' class='textbox' size='35'></td>
        </tr>
        <tr>
            <td>Bio / About:</td>
            <td><textarea name='bio' cols='35' rows='5' class='textbox'></textarea></td>
        </tr>
        <tr>
            <td>Enter Code:</td>
            <td><input name='code' type='text'/><img src='captcha.php'/></td>
        </tr>
        <tr>
            <td></td>
            <td><input type='submit' name='submitbtn' value='Register An Account' class='button'>
                <input type='reset' name='resetbtn' value='Reset Information' class='button'>
            </td>
        </tr>

        </table>
        </form>"
    ;
        
        if (
    $_POST['submitbtn']){
            
            
    $firstname fixtext($_POST['firstname']);
            
    $lastname fixtext($_POST['lastname']);
            
    $username fixtext($_POST['username']);
            
    $email fixtext($_POST['email']);
            
    $password fixtext($_POST['password']);
            
    $repassword fixtext($_POST['repassword']);
            
    $website fixtext($_POST['website']);
            
    $youtube fixtext($_POST['youtube']);
            
    $bio fixtext($_POST['bio']);
            
            
    $name $_FILES['avatar']['name'];
            
    $type $_FILES['avatar']['type'];
            
    $size $_FILES['avatar']['size'];
            
    $tmpname $_FILES['avatar']['tmp_name'];
            
    $ext substr($namestrrpos($name'.'));
            
            
            
            
            if (
    $firstname && $lastname && $username && $email && $password && $repassword){
              
                if (
    $password == $repassword) {
                    if (
    strstr($email"@") && strstr($email".") && (strlen($email) >= 6)) {
                        
                        require(
    "scripts/connect.php");
                        
                        
    $query mysql_query("SELECT * FROM users WHERE username='$username'");
                        
    $numrows mysql_num_rows($query);
                        if (
    $numrows == 0){
                            
                            
    $query mysql_query("SELECT * FROM users WHERE email='$email'");
                            
    $numrows mysql_num_rows($query);
                            if (
    $numrows == 0){
                                
                                
    $pass md5(md5($password));
                                
    $date date("F d, Y"); // Febuary 09, 2013
                                
                                
    if ($name){
                                    
    move_uploaded_file($tmpname"avatars/$username.$ext");
                                    
    $avatar $username.$ext;
                                }
                                else
                                    
    $avatar "defavatar.png";
                                    
                                    
    $code substr(md5(rand(11111111119999999999)), 225);
    //Captcha Code Starts Here                            


                                
    if(md5($_POST['code']) != $_SESSION['key']) 
                                    die(
    "You've entered a wrong code!");

    //Capcha Code Ends Here
                                
                                
    mysql_query("INSERT INTO users VALUES ('', '$firstname', '$lastname', '$username', '$email', '$pass','$avatar', '$bio', '$website', '$youtube', '', '1', '$code', '0', '$date')");
                                
                                
    $webmaster "mark@mbappz.com";
                                
    $subject "Registration Details";
                                
    $headers "From: Mark<$webmaster>";
                                
    $message "Hello $firstname.  Welcome to MBAPPZ.com.  Below is your details for login on MBAPPZ.com.\n\n Username: $username \n\n Password: $password";
                                
                                
    mail($email$subject$message$headers);
                                
                                echo 
    "Thank You for registering your account with us your registration details will be emailed to your email address on file.  If you are having problems please contact the sites administrator at <a href='mailto:mark@mbappz.com'>Mark@mbappz.com</a>.";
                                
                            }
                            else
                                echo 
    "That email is already taken. $form";
                        }
                        else
                            echo 
    "That username is already taken. $form";
                    }
                    else
                        echo 
    "You did not enter a valid email address. $form";
                }
                else
                    echo 
    "Your passwords did not match. $form";
            }
            else
                echo 
    "You did not fill in all the required fields. $form";
                
        }
        else
            echo 
    "$form";

        
    ?>
            </div>
            
            <div id='right'>
                    <div class='box'>
            <div class='top'>Latest Members</div>
            <div class='bottom'>
                <?php require("scripts/members.php"); ?>
            </div>
            </div>
            <br />
            <div class='box'>
            <div class='top'>Latest Tutorials</div>
            <div class='bottom'>
                <?php require("scripts/tutorials.php"); ?>
            </div>
            </div>
            </div>

    <?php require("styles/bottom.php"); ?>
    Last edited by Jamie_Garland; Jun 24th, 2013 at 06:06 PM.
    come back and mark your original post as resoved if your problem is fixed

    Jamie Garland

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,537

    Re: captcha Problem

    it's doing exactly what you told it to do.... die .... that means "Print out this message and the just stop."

    die("You've entered a wrong code!");

    if you want it to keep processing, then don't use the die command.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2004
    Posts
    1,202

    Re: captcha Problem

    how do i use the echo code with the code i use as it working but the footer seems to disappear ?.
    come back and mark your original post as resoved if your problem is fixed

    Jamie Garland

  4. #4
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: captcha Problem

    Change

    PHP Code:
    if(md5($_POST['code']) != $_SESSION['key']) 
      die(
    "You've entered a wrong code!");

    //Capcha Code Ends Here
                                
       
    mysql_query("INSERT INTO users VALUES ('', '$firstname', '$lastname', '$username', '$email', '$pass','$avatar', '$bio', '$website', '$youtube', '', '1', '$code', '0', '$date')");
                                
      
    $webmaster "mark@mbappz.com";
      
    $subject "Registration Details";
      
    $headers "From: Mark<$webmaster>";
      
    $message "Hello $firstname.  Welcome to MBAPPZ.com.  Below is your details for login on MBAPPZ.com.\n\n Username: $username \n\n Password: $password";
                                
      
    mail($email$subject$message$headers);
                                
      echo 
    "Thank You for registering your account with us your registration details will be emailed to your email address on file.  If you are having problems please contact the sites administrator at <a href='mailto:mark@mbappz.com'>Mark@mbappz.com</a>."
    to

    PHP Code:
    if(md5($_POST['code']) == $_SESSION['key']) 
    {
      
    //Capcha Code Ends Here
                                
      
    mysql_query("INSERT INTO users VALUES ('', '$firstname', '$lastname', '$username', '$email', '$pass','$avatar', '$bio', '$website', '$youtube', '', '1', '$code', '0', '$date')");
                                
      
    $webmaster "mark@mbappz.com";
      
    $subject "Registration Details";
      
    $headers "From: Mark<$webmaster>";
      
    $message "Hello $firstname.  Welcome to MBAPPZ.com.  Below is your details for login on MBAPPZ.com.\n\n Username: $username \n\n Password: $password";
                                
      
    mail($email$subject$message$headers);
                                
      echo 
    "Thank You for registering your account with us your registration details will be emailed to your email address on file.  If you are having problems please contact the sites administrator at <a href='mailto:mark@mbappz.com'>Mark@mbappz.com</a>.";    
    }
    else
    {
      echo 
    "You've entered a wrong code!";

    I also notice you're not using parameterized queries to insert values into your database. You should be. Look into PDO.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width