Jump to content

Chrisj

Members
  • Posts

    551
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Chrisj

  1. Can you please tell me what each of these lines of code means?

    $allowedExts = array("gif", "jpeg", "jpg", "png");
    $temp = explode(".", $_FILES["file"]["name"]);
    $extension = strtolower( end($temp) );
    $length = 20;
    $newfilename = $_SESSION['user_id'].$_FILES["file"]["name"];
    $thumbnail = $newfilename . "." . $extension;
    move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $thumbnail);
    $sql = "INSERT INTO videos ( filename ) VALUES( $thumbnail )";
    mysql_query($sql);
    $file_location = '<a href="http://www.--.com/upload/' . $thumbnail . '">' . $thumbnail . '</a>';
    $description = $description . " \n " . $newfilename;
    
  2. In an Upload Form that I'm using, it has this line:

    $newfilename = $SESSION['userid'].$_FILES["file"]["name"];
    

    I need to "store the newfilename in a session variable" (in another php file)

    and use the session variable in this link, instead of newfilename:

    <a href="upload/<?php echo $newfilename?>"><?php echo $newfilename?></a>

    So, would this be correct?

    $newfilename = $_SESSION['newfilename'].$_FILES["newfilename"];
    
  3. This change now gets the image uploaded, however this code takes me to the next page.

    I'd like to figure out how to stay on the same page after upload. Any help will be appreciated.

    <form enctype="multipart/form-data" action="" method="POST">
    <input type="file" name="file" id="file">
    <input class="upload-input" type="hidden" name="form_submitted" value="yes" />
    <input type="submit" value="submit" />
    </form>
    
  4. I don't know why this image upload code isn't uploading the image file to the uploads/ folder.

    Any help will be appreciated.

    	$allowedExts = array("gif", "jpeg", "jpg", "png");
    	$temp = explode(".", $_FILES["file"]["name"]);
    	$extension = strtolower( end($temp) );
    	if (  $_FILES["file"]["size"] < 2000000
    	&& in_array($extension, $allowedExts) )
    	{
    	if ($_FILES["file"]["error"]!= 0)
    	{
    	echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
    	} else {
    	$length = 20;
    	$randomString = substr(str_shuffle(md5(time())),0,$length);
    	$newfilename = $randomString . "." . $extension;
    	move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $newfilename );
    	$file_location = '<a href="http://www.--.com/upload/' . $newfilename . '">http://www.--.com/upload/' . $newfilename . '</a>';
    	}
    	} else {
    	echo "Invalid upload file";
    	}
    
    <form enctype="multipart/form-data" action="uploader.php">
    <input type="file" name="file" id="file">
    <input type="submit" name="submitted" value="Submit">
    </form>
    
  5. Thanks for that, however this code (below) doesn't successfully display the path of the chosen file, on the html page, like so:

    ../upload/test.png
    Any help/improvements will be appreciated.

    <html>
     <head>
      <title>PHP Test</title>
     </head>
      <body>
     <?php
     if ($form_submitted == 'yes') {
     $allowedExts = array("gif", "jpeg", "jpg", "png");
     $temp = explode(".", $_FILES["file"]["name"]);
     $extension = strtolower( end($temp) );
     $newfilename = md5($_FILES['tmp']['name'] . time()) . '.' . $extension;
     if (  $_FILES["file"]["size"] < 200000
           && in_array($extension, $allowedExts) )
     {
         if ($_FILES["file"]["error"]!= 0)
         {
             echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
         } else {
             $length = 20;
             move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $newfilename );
             $file_location = '<a href="http://www.--.com/upload/' . $newfilename . '">' . $newfilename . '</a>';
         }
     } else {
       echo "Invalid upload file";
     }
     $description = $description . "\n http://www.--.com/upload/" . $newfilename;
     }
    ?>
    <label for="file">Filename:</label>
    <input type="file" name="file" id="file">
    </body>
    </html>
    
  6. I need help making the uploaded image file name, that's chosen to be uploaded, be displayed on the html page with the path /upload/ added to the beginning of the displayed file name like so:
    ../upload/test.png
    Any help/improvements will be appreciated.

    <html>
     <head>
      <title>PHP Test</title>
     </head>
      <body>
     <?php
     if ($form_submitted == 'yes') {
     $allowedExts = array("gif", "jpeg", "jpg", "png");
     $temp = explode(".", $_FILES["file"]["name"]);
     $extension = strtolower( end($temp) );
     if (  $_FILES["file"]["size"] < 200000
           && in_array($extension, $allowedExts) )
     {
         if ($_FILES["file"]["error"]!= 0)
         {
             echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
         } else {
             $length = 20;
             move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $newfilename );
             $file_location = '<a href="http://../upload/' . $newfilename . '">' . $newfilename . '</a>';
         }
     } else {
       echo "Invalid upload file";
     }
    ?>
    <label for="file">Filename:</label>
    <input type="file" name="file" id="file">
    </body>
    </html>
    
  7. I've added this code (below) to a file called uploader.php (attached).

     

    When I simply open the corresponding html page, I see "Invalid upload file" in the top left corner of the page. When I remove this code from uploader.php the "Invalid upload file" disappears. Any ideas on how to resolve this will be appreciated.

    $allowedExts = array("gif", "jpeg", "jpg", "png");
    $temp = explode(".", $_FILES["file"]["name"]);
    $extension = strtolower( end($temp) ); // in case user named file ".JPG" etc.!!!
    
    if (  $_FILES["file"]["size"] < 200000 
          && in_array($extension, $allowedExts) )
    {
        if ($_FILES["file"]["error"] > 0) 
        {
            echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
        } else {
            $length = 20;
            $randomString = substr(str_shuffle(md5(time())),0,$length);
            $newfilename = $randomString . "." . $extension;
            move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $newfilename);
          
           $file_location = '<a href="http://www.-----.com/upload/' . $newfilename . '">' . $newfilename . '</a>';
        }
    } else {
      echo "Invalid upload file";
    }
    $description = $description . " \n " . $newfilename;
    
  8. thanks for your reply.

    I plugged in your code that you "switched around a little" and after logging in I was re-directed to the /myaccount.php page.

    Although i appreciate your help, that isn't what i was hoping for.

     

    The code that shows in my initial post, logs-in successfully (from the home page) and then shows the sub-menu things on the home page.

    (But it also shows the log-in Form still on the homepage). I'd like to stay on the home page (with the sub menu stuff)and not be re-directed (but just have the log-in form disappear after succeeding). 

     

    Any additional help will be appreciated.

  9. When I asked how to make this Log In Form disappear once it performs it's function:

    <form action="../login.php" method="post" accept-charset="UTF-8" class="middletext"
    onsubmit="javascript:this.style.display='none';">
    <p>
    <input type="text" size="20" name="user_name_login" id="user_name_login" value="ENTER     USERNAME" style="color:#D9D9D9" style="vertical-align:middle"; onfocus="if     (this.value=='ENTER USERNAME') {this.value=''; this.style.color='#696969';}" >
    <input type="text" size="20" name="password_login" id="password_login" value="ENTER     PASSWORD" style="color:#D9D9D9" style="vertical-align:middle"; onfocus="if     (this.value=='ENTER PASSWORD') {this.value=''; this.style.color='#696969';}" >
    <input type="hidden" name="cookie_time" value="10080" />
    <img src="../themes/default/images/arrow-red.png" alt="" /><input type="submit"   style="outline:grey" font-size="5px" value="[var.lang_login_now]" class="button-form2" />
    <input type="hidden" name="submitted" value="yes" />
    <input type="hidden" name="remember_me" value="remember_me" />
    </p>
    </form>
    </div>
    <!--Begin Sub-Navigation. This only appears when a user is logged in.-->
    <div class="container1">
    <div class="menu1">
    <div class="sub-nav"><a href="../index.php"></a> <img     src="../themes/default/images/arrow-red.jpg" style="vertical-align:middle" alt="" /><a    href="../members/[var.user_name]"> my account</a><img src="../themes/default/images/arrow-    red.jpg" style="vertical-align:middle" alt="" />
    <a href="../credits.php">[var.lang_my_credits]: [var.member_credits]</font></a><img     src="../themes/default/images/arrow-red.jpg" style="vertical-align:middle"><a     href="../logout.php">[var.login_out]</a>
    <!--[onload;block=div;when [var.loggedin]=1;comm]-->
    </div>
    

    I was given this line of code:

    if($_SESSION['loggedin'] == true){ //dont show form } else { //show form }
    

    But I don't know how/where to integrate it into the Form.

    Any help will be appreciated.

  10. I'm using an Upload Script, and I've been working on trying to style the 'Choose File Button' (input file button)
    which was a challenge to be styled for multiple browsers, but finally works with Google, IE and FF.
     
    However, now that I've successfully styled the input file button, when a file is now chosen, the chosen file name no longer appears, prior to Submit.
     
    I've attached an image of the code changes I made, plus some CSS styling, and this addition:
     
    label input[type="file"] {
        position: fixed;
        top: -1000px;
    

    Any suggestions/ideas/remedy on how to get the chosen file to show (or something to show an action has taken place) will be appreciated

    post-20454-0-21615100-1405917399_thumb.png

  11. Thanks for your reply.

    I tried to quickly shorten the list of file formats, when copying it here, just so there would be less to read in this posting.

    So, that last quote issue, isn't in the actual code.

    And I was aware of the header in two places.

    Which I've corrected. Not sure about your MySQL comment. Would that affect the browser issue?

    Here's the revised code with no "last quote" and only one "header".

    Any additional help will be greatly appreciated.

    <?php
    session_start();
    require_once 'phps3integration_lib.php';
    $message = "";
    if (@$_POST['submit'] != "") {
    $allowed_ext = array("gif", "jpeg", "jpg", "png", "pdf", "doc", "docs", "zip" , "mov", "flv", "mp4", "3gp");
    $extension = end(explode(".", $_FILES["fileBrowser"]["name"]));
    if (($_FILES["fileBrowser"]["size"] < 10485760) && in_array($extension, $allowed_ext)) {
    if ($_FILES["fileBrowser"]["error"] > 0) {
    //$message.="There is some error in upload, see: " . $_FILES["fileBrowser"]["error"] . "<br>";//Enable this to see actual error
    $message.="There is some error in upload. Please try after some time.";
    } else {
    $uploaded_file = uploaded_file_to_s3($_FILES["fileBrowser"], "uploads", true);
    if ($uploaded_file != FALSE) {
    $user_name = @$_POST['user_name'] != "" ? @$_POST['user_name'] : "Anonymous";
    $form_data = array(
    'file' => $uploaded_file,
    'user_name' => $user_name,
    'type' => 'file'
    );
    mysql_query("INSERT INTO `phps3files` (`id`, `file`, `user_name`, `type`) VALUES (NULL, '" . $uploaded_file . "', '" . $user_name . "', 'file')") or die(mysql_error());
    $message.= "File Successfully Uploaded.";
    } else {
    $message.="There is some error in upload. Please try after some time.";
    }
    }
    } else {
    $message.= "Upload Unsuccessful. Please Contact Administrator";
    }
    }
    ?>
    
    <html>
    <head><br /><br /><br />
    <font size="6" color="#c53800"><b>Upload:</b></font><br /><br />
    </head>
    
    <style>
    button { background: #bi4e4e; color: red; }
    </style>
    
    
    <body>
    <?php require_once 'header.php'; ?>
    
    <!--<fieldset>-->
    <form action="upload_file.php" method="post" enctype="multipart/form-data">
    
    <div class="control-group">
    <label for="file" class="control-label"><font size="6" color="#454545"><b>Choose a file to upload:</b></font></label>
    <button type="button" onclick="getFilePathFromDialog();">ChooseFile</button>
    <input type="text" id="filePath" name="filePath"/><br />
    <input type="file" id="fileBrowser" name="fileBrowser"style="visibility:hidden; display:none;" />
    <?php //echo form_error('file'); ?>
    </div>
    
    <script>
    function getFilePathFromDialog() {
    document.getElementById('fileBrowser').click();
    document.getElementById('filePath').value =
    document.getElementById('fileBrowser').value;
    }
    </script>
    </html>
    
    <div class="control-group">
    <label></label>
    <div class='controls'>
    <input type="image" src="/images/upload.png" name="submit" value="Upload">
    </div>
    </div>
    </form>
    
    
    <?php
    if ($message != "" || @$_SESSION['message'] != "") {
    ?>
    <div class="alert alert-success">
    <?php echo $message; ?>
    <?php
    echo @$_SESSION['message'];
    @$_SESSION['message'] = '';
    ?>
    </div>
    <?php
    }
    ?>
    <div>
    </div>
    
    <?php require_once 'footer.php'; ?>
    
  12. The upload script I'm using performs successfully in Google, but not in IE or FF.
    In Google, it doesn't fill the box with the path(see image), but it shows a message of successful upload.
    In IE, it fills the box with the path, but the path begins with C:\fakepath\... and doesn't upload or show unsuccessful upload message. In FF, my computer shows something's uploading, but it doesn't appear in AmazonS3 nor does it fill the box, or show any message.
    I'm not interested in starting over with a different script, I'd just like to get some suggestions/ideas/remedy for this one, please. Thanks for any help
     
    <?php
    session_start();
    require_once 'phps3integration_lib.php';
    $message = "";
    if (@$_POST['submit'] != "") {
    $allowed_ext = array("gif", "jpeg", "jpg", "png", "pdf", "doc", "docs", "zip" , "mov", "flv", "mp4", "3gp", ");
    $extension = end(explode(".", $_FILES["fileBrowser"]["name"]));
    if (($_FILES["fileBrowser"]["size"] < 10485760) && in_array($extension, $allowed_ext)) {
    if ($_FILES["fileBrowser"]["error"] > 0) {
    //$message.="There is some error in upload, see: " . $_FILES["fileBrowser"]["error"] . "<br>";//Enable this to see actual error
    $message.="There is some error in upload. Please try after some time.";
    } else {
    $uploaded_file = uploaded_file_to_s3($_FILES["fileBrowser"], "uploads", true);
    if ($uploaded_file != FALSE) {
    $user_name = @$_POST['user_name'] != "" ? @$_POST['user_name'] : "Anonymous";
    $form_data = array(
    'file' => $uploaded_file,
    'user_name' => $user_name,
    'type' => 'file'
    );
    mysql_query("INSERT INTO `phps3files` (`id`, `file`, `user_name`, `type`) VALUES (NULL, '" . $uploaded_file . "', '" . $user_name . "', 'file')") or die(mysql_error());
    $message.= "File Successfully Uploaded.";
    } else {
    $message.="There is some error in upload. Please try after some time.";
    }
    }
    } else {
    $message.= "Upload Unsuccessful. Please Contact Administrator";
    }
    }
    ?>
    
    <?php
    require_once 'header.php';
    ?>
    
    <html>
    <head><br /><br /><br />
    <font size="6" color="#c53800"><b>Upload:</b></font><br /><br />
    </head>
    
    <style>
    button { background: #bi4e4e; color: red; }
    </style>
    
    
    <body>
    <?php require_once 'header.php'; ?>
    
    <!--<fieldset>-->
    <form action="upload_file.php" method="post" enctype="multipart/form-data">
    
    <div class="control-group">
    <label for="file" class="control-label"><font size="6" color="#454545"><b>Choose a file to upload:</b></font></label>
    <button type="button" onclick="getFilePathFromDialog();">ChooseFile</button>
    <input type="text" id="filePath" name="filePath"/><br />
    <input type="file" id="fileBrowser" name="fileBrowser"style="visibility:hidden; display:none;" />
    <?php //echo form_error('file'); ?>
    </div>
    
    <script>
    function getFilePathFromDialog() {
    document.getElementById('fileBrowser').click();
    document.getElementById('filePath').value =
    document.getElementById('fileBrowser').value;
    }
    </script>
    </html>
    
    <div class="control-group">
    <label></label>
    <div class='controls'>
    <input type="image" src="/images/upload.png" name="submit" value="Upload">
    </div>
    </div>
    </form>
    
    
    <?php
    if ($message != "" || @$_SESSION['message'] != "") {
    ?>
    <div class="alert alert-success">
    <?php echo $message; ?>
    <?php
    echo @$_SESSION['message'];
    @$_SESSION['message'] = '';
    ?>
    </div>
    <?php
    }
    ?>
    <div>
    </div>
    
    <?php require_once 'footer.php'; ?>
    

     

  13. I'm using an Upload Form and I believe this line of code, shown below, is what the attached image shows (see attached image).

     

    How can I add a different image button to replace the "Choose File" button that's currently there?

     

    Also, how can I put some space between the Choose File button and the "No File Chosen" function?

     

    Thanks

    <div class='controls'>
    <input id="file" type="file" name="file" />
    <?php //echo form_error('file');   ?></div>
    
  14. I'm trying to separate the HTML(form) into a separate .html file (from the php file below).
    Someone suggested to "place the HTML in someFile.html and the PHP in someFile.php, and alter the <form> tag's 'action' element in the .html file to target someFile.php".

    But I don't know how to alter the <form> tag's 'action' element in the .html file to target this upload_file.php file.

    Any additional help will be appreciated.

    <?php
    session_start();
    require_once 'phps3integration_lib.php';
    $message = "";
    if (@$_POST['submit'] != "") {
    $allowed_ext = array("gif", "jpeg", "jpg", "png", "pdf", "doc", "docs", "zip", "flv", "mp4");
    $extension = end(explode(".", $_FILES["file"]["name"]));
    if (($_FILES["file"]["size"] < 32428800) && in_array($extension, $allowed_ext)) {
    if ($_FILES["file"]["error"] > 0) {
    //$message.="There is some error in upload, see: " . $_FILES["file"]["error"] . "<br>";//Enable this to see actual error
    $message.="There is some error in upload. Please try after some time.";
     } else {
    $uploaded_file = uploaded_file_to_s3($_FILES["file"], "uploads", true);
     if ($uploaded_file != FALSE) {
    $user_name = @$_POST['user_name'] != "" ? @$_POST['user_name'] : "Anonymous";
    $form_data = array(
    'file' => $uploaded_file,
    'user_name' => $user_name,
    'type' => 'file'
     );
    mysql_query("INSERT INTO `phps3files` (`id`, `file`, `user_name`, `type`) VALUES (NULL, '" . $uploaded_file . "', '" . $user_name . "', 'file')") or die(mysql_error());
    $message.= "File successfully uploaded in S3 Bucket.";
    } else {
    $message.="There is some error in upload. Please try after some time.";
    }
    }
    } else {
    $message.= "Invalid file, Please upload a gif/jpeg/jpg/png/pdf/doc/docs/zip file of maximum size 30 MB.";
    }
    }
    ?>
    <?php
    require_once 'header.php';
    ?>
    <fieldset>
    <legend>PHP AWS S3 integration library Demo1</legend>
    Description: In this demo a file is being upload to an S3 bucket using "PHP AWS S3 integration library". After upload you can check the uploaded file in below table.
    If you require some manipulation before uploading file to S3 then check <a href="upload_file_manually.php">Demo2</a> <br />
    <br />
    
    <form action="" method="post" enctype="multipart/form-data">
    
    <div class="control-group">
    <label for="file" class="control-label">Choose a file to upload: <span style="color:red">*</span></label>
    <div class='controls'>
     <input id="file" type="file" name="file" />
    <?php //echo form_error('file');   ?> </div>
    </div>
    <div class="control-group">
    <label for="user_name" class="control-label">Your name:</label>
    <div class='controls'>
    <input id="user_name" type="text" name="user_name" maxlength="255" value=""  />
    <?php //echo form_error('user_name');   ?> </div>
    </div>
    <div class="control-group">
    <label></label>
    <div class='controls'>
    <input type="submit" name="submit" value="Submit" class="btn">
    </div>
    </div>
    </form>
    </fieldset>
    <?php
    if ($message != "" || @$_SESSION['message'] != "") {
    ?>
    <div class="alert alert-success">
    <?php echo $message; ?>     
    <?php
    echo @$_SESSION['message'];
    @$_SESSION['message'] = '';
    ?>
    </div>
    <?php
    }
    ?>
    <div>
    <table  class="table table-hover">
     <caption>
     <strong>Last 10 user uploaded files</strong>
    </caption>
    <?php
    $files_result = mysql_query("SELECT * from `phps3files` WHERE type LIKE 'file' ORDER by id DESC LIMIT 10");
    $i = 1;
    while ($file = mysql_fetch_object($files_result)) {
    ?>
    <tr>
    <td><?php echo $i++; ?></td>
    <td><a href="<?php echo site_url_s3("uploads/" . $file->file); ?>" target="_blank">View/Download</a> </td>
    <td><a href="<?php echo site_url("delete_file.php?id=" . $file->id); ?>">Delete file from S3</a></td>
    <td><?php echo "Uploaded by: " . $file->user_name; ?></td>
    </tr>
    <?php
    }
    if ($i == 1) {
    ?>
    <tr>
     <td colspan="2"> No files uploaded yet</td>
    </tr>
    <?php
    }
    ?>
    </table>
    </div>
    <h4>Source Code Part of Demo</h4>
    <pre class="prettyprint lang-php linenums">
    <?php
    session_start();
    require_once 'phps3integration_lib.php';
    $message = "";
    if (@$_POST['submit'] != "") {
    $allowed_ext = array("gif", "jpeg", "jpg", "png", "pdf", "doc", "docs", "zip");
    $extension = end(explode(".", $_FILES["file"]["name"]));
    if (($_FILES["file"]["size"] < 32428800) && in_array($extension, $allowed_ext)) {
     if ($_FILES["file"]["error"] > 0) {
    //$message.="There is some error in upload, see: " . $_FILES["file"]["error"] . "<br>";//Enable this to see actual error
    $message.="There is some error in upload. Please try after some time.";
     } else {
    $uploaded_file = uploaded_file_to_s3($_FILES["file"], "uploads", true);
    if ($uploaded_file != FALSE) {
    $user_name = @$_POST['user_name'] != "" ? @$_POST['user_name'] : "Anonymous";
    $form_data = array(
     'file' => $uploaded_file,
     'user_name' => $user_name,
     'type' => 'file'
     );
    mysql_query("INSERT INTO `phps3files` (`id`, `file`, `user_name`, `type`) VALUES (NULL, '" . $uploaded_file . "', '" . $user_name . "', 'file')") or die(mysql_error());
    $message.= "File successfully uploaded in S3 Bucket.";
    } else {
    $message.="There is some error in upload. Please try after some time.";
    }
    }
    } else {
    $message.= "Invalid file, Please upload a gif/jpeg/jpg/png/pdf/doc/docs/zip file of maximum size 30 MB.";
    }
    }
    ?>
    </pre>
    <?php require_once 'footer.php'; ?>
    
  15. What file size is allowed with this code?

    if (@$_POST['submit'] != "") {
        $allowed_ext = array("gif", "jpeg", "jpg", "png", "pdf", "doc", "docs", "zip", "flv", "mp4");
        $extension = end(explode(".", $_FILES["file"]["name"]));
        if (($_FILES["file"]["size"] < 524288000) && in_array($extension, $allowed_ext)) {
    
  16. Thanks for your replies.

    I also have this code:

    <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
    <script>
        $(function() {
        $('input.required').click(function() {
            var unchecked = $('input.required:not(:checked)').length;
            if (unchecked == 0) {
                $('#submitBtn').removeAttr('disabled');
            }
            else {
                $('#submitBtn').attr('disabled', 'disabled');
            }
            });
        });
    </script>
    

    Does that make it more like "how it should be done"? I look forward to your reply.

  17. Can you help me integrate this code :

    <form method="post" action="submit.php">
    <input type="checkbox" class="required" /> Click to check
    <br />
    <input disabled="disabled" type='submit' id="submitBtn" value="Submit">
    </form>
    

    In to this Contact Form code, please?

    <form action="../page.php?page=1" method="post" name="contact_us" onSubmit="return capCheck(this);">
    <table cellpadding="5" width="100%">
    <tr>
    <td width="10" class="required_field">*</td>
    <td width="80">Your Name</td>
    <td><input type="text" name="name" maxlength="40" style="width:400px;/></td>
    </tr>
    <tr>
    <td class="required_field">*</td>
    <td>Email Address</td>
    <td><input type="text" name="email" maxlength="40" style="width:400px;/></td>
    </tr>
    <tr>
    <td></td>
    <td>Comments:</td>
    <td><textarea name="comments" style="width: 400px; height: 250px;"></textarea></td>
    </tr>
    </table>
    </form
    
  18. This contact form works fairly well, but I do get spam.

    Can you add something to this existing form that will make it a little better at not letting spam thru?

    <form action="../page.php?page=1" method="post" name="contact_us" onSubmit="return capCheck(this);">
    <table cellpadding="5" width="100%">
    <tr>
    <td width="10" class="required_field">*</td>
    <td width="80">Name</td>
    <td><input type="text" name="name" maxlength="50" style="width:400px; border: 1px solid #696969;" /><br /><br /></td>
    </tr>
    <tr>
    <td class="required_field">*</td>
    <td>Email Address</td>
    <td><input type="text" name="email" maxlength="40" style="width:400px; border: 1px solid #696969;" /><br /><br /></td>
    </tr>
    <tr>
    <td></td>
    <td>Subject:</td>
    <td><input type="text" name="subject" maxlength="40" style="width:400px; border: 1px solid #696969;"/><br /><br /></td>
    </tr>
    <tr>
    <td class="required_field">*</td>
    <td>Enter Image Code:</td>
    <td><input type="text" value="" name="captext" style="width: 100px" maxlength="6" /></td>
    </tr>
    <tr>
    <td></td>
    <td><a onclick="refresh_security_image(); return false;" style="cursor:pointer;"><u>Refresh Image</u></a></td>
    <td><img src="../includes/captcha.php" border="0" id="verificiation_image" /></a></td>
    </tr>
    </table>
    <br/>
    <p>
    <input type="hidden" name="submited" value="1" />
    <input type="submit" name="submit" value="Submit" style="margin:7px 10px 0px 0px; padding:10px 0px 10px 0px; font-size:15px; font-style:Century-Gothic;" />
    </p>
    </form>
    </td>
    </tr>
    </table>
    </div>
    <script type="text/javascript">
    <!--
    function refresh_security_image() {
    
    var new_url = new String("../includes/captcha.php?width=132&height=36&charcators=");
    new_url = new_url.substr(0, new_url.indexOf("width=") + 37);
    // we need a random new url so this refreshes
    var chr_str = "123456789";
    for(var i=0; i < 6; i++)
    new_url = new_url + chr_str.substr(Math.floor(Math.random() * 2), 1);
    document.getElementById("verificiation_image").src = new_url;
    }
    -->
    </script>
    
    <!-- captch start -->
    <script type="text/javascript" id="clientEventHandlersJS" language="javascript">
    </script>
    <!-- captch end -->
    
    

    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.