The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 5 of 5

Thread: CAPTCHA - PHP code within HTML

  1. #1

    CAPTCHA - PHP code within HTML

    Hi guyz

    I'm making a contact form which has name, address, etc... and a captcha field at the bottom of the form before the submit button. i am working on my local computer, everything works fine, no problem at all.

    Now, after a I uploaded my files to the actual site, it's just so strange that my captcha image isn't displaying on where it has to be.

    The form is on an HTML page, contact.htm:
    Here's the code for my form...
    Code:
    <form name="myform" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
    <table border="0" width="100%" cellpadding="0" style="border: 1px solid #ededed; border-collapse: collapse" height="322" id="send">
      <tr>
        <td width="100%" colspan="3" height="24" bgcolor="#F2F9F2">
        <p style="margin-left: 10px"><strong>
        <font face="Tahoma" size="2">Send us
        your comments and suggestions</font></strong></td>
    </tr>
    <tr>
        <td colspan="3"><font size="1">&nbsp;</font></td>
    </tr>
    <tr>
        <td colspan="3" style="list-style: none;"><font style="font-size: 8pt;" face="Tahoma" color="#ff0000">
            <div id='myform_errorloc'></div></font>
          </td>
    </tr>
    <tr>
        <td width="24%" align="right">
        <p style="margin-right: 20px">
        <font face="Tahoma" style="font-size: 9pt">
        Name</font></td>
        <td colspan="2">
        <input type="text" name="name" value="<?php echo htmlentities($name); ?>" size="55" style="font-family: Tahoma; font-size: 9pt" id="name"></td>
    </tr>
    <tr>
        <td width="24%" align="right">
        <p style="margin-right: 20px">
        <font face="Tahoma" style="font-size: 9pt">
        Email</font></td>
        <td colspan="2">
        <input type="text" name="email" value="<?php echo htmlentities($email); ?>" size="55" style="font-family: Tahoma; font-size: 9pt" id="name0"></td>
    </tr>
    <tr>
        <td width="24%" align="right">
        <p style="margin-right: 20px">
        <font face="Tahoma" style="font-size: 9pt">
        Address</font></td>
        <td colspan="2">
        <input type="text" name="address" value="<?php echo htmlentities($address); ?>" size="55" style="font-family: Tahoma; font-size: 9pt" id="name2"></td>
    </tr>
    <tr>
        <td width="24%" align="right">
        <p style="margin-right: 20px">
        <font face="Tahoma" style="font-size: 9pt">
        Contact No.</font></td>
        <td colspan="2">
        <input type="text" name="contact" value="<?php echo htmlentities($contact); ?>" size="55" style="font-family: Tahoma; font-size: 9pt" id="name1"></td>
    </tr>
    <tr>
        <td width="24%" align="right" valign="top" height="88">
        <p style="margin-right: 20px">
        <font face="Tahoma" style="font-size: 9pt">
        Message</font></td>
        <td valign="top" height="88" colspan="2">
        <textarea rows="6" name="message" cols="52" style="font-family: Tahoma; font-size: 9pt" id="message"><?php echo htmlentities($message); ?></textarea></td>
    </tr>
    <tr>
        <td width="24%" align="right" valign="top" height="24">&nbsp;</td>
        <td width="21%" height="24">
    <img src="functions/captcha_code_file.php?rand=<?php echo rand(); ?>" id='captchaimg' >
        </td>
        <td height="24" width="54%">
        <font face="Tahoma" style="font-size: 8pt" color="#444444">
        Can't read the image? </font>
        <font face="Tahoma" style="font-size: 8pt" color="#FF0000">
        <a href="javascript: refreshCaptcha();">
        <font color="#FF0000">Click here</font></a></font></td>
    </tr>
    <tr>
        <td width="24%" align="right" valign="top" height="10"></td>
        <td colspan="2" height="10">
        <font face="Tahoma" style="font-size: 8pt" color="#444444">
        Enter the code above here</font></td>
    </tr>
    <tr>
        <td width="24%" align="right" valign="top" height="20">&nbsp;</td>
        <td colspan="2" height="20">
        <input type="text" name="6_letters_code" size="22" style="font-family: Tahoma; font-size: 9pt" id="6_letters_code"></td>
    </tr>
    <tr>
        <td width="24%" align="right" valign="top">&nbsp;</td>
        <td colspan="2">
        <input type="submit" value="Send" name="sendBtn" style="font-family: Tahoma; font-size: 8pt"></td>
    </tr>
    <tr>
        <td width="24%" align="right" valign="top" height="19">&nbsp;</td>
        <td colspan="2" height="19">&nbsp;</td>
    </tr>
    </table>
    </form>
    This is the source of my captcha image inside the form..
    Code:
    <img src="functions/captcha_code_file.php?rand=<?php echo rand(); ?>" id='captchaimg' >
    The captcha_code_file.php will just produce the image.
    I'm using .htaccess to read php scripts in html.. here's my .htaccess code...
    Code:
    AddType application/x-httpd-php .htm .html
    all php scripts are running but only this captcha codes isn't doing right.
    any help is greatly appreciated..thank you.

  2. #2
    Can you see the captcha image if you directly access the image using URL like
    http://www.yourwebsite.com/functions/captcha_code_file.php?rand=200

    If there is some error, it will display the error in the browser when you access the captcha script directly.

  3. #3
    No, the image isn't displaying when i directly access the page..It will just display the plain current url you are in, but not the image.

    But everything works fine with my local computer.

    Is there anything to do with file extensions, or the .htaccess or any modules??
    Please help..thank you.

  4. #4
    You are probably missing the GD extension in the server. Check phpinfo() and see if GD is installed, else you'll have to ask your sysadmin to install it for you, or if you have shell access, install it yourself.

  5. #5
    If it isn't the GD library, check to make sure you have PHP5+ installed as I had the same problem last year with a CAPTCHA that wouldn't display

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012