Jump to content
Old threads will finally start getting archived ×

Chrisj

Members
  • Posts

    551
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Chrisj

  1. I've installed a pre-written cms type PHP web script and am interested in modifying it. I've only worked with earlier versions of PHP, but I'm going thru a learning curve with this one. I'm simply trying to modify some text (on the scripts' log in page, for example, to begin with). The text, as an example, on the displayed log-in page shows:

    "You have not signed up for your free account. The registration process is quick and easy....." and that log-in.php file's code led me to my db and the table named 'pages', where in the 'content' column the text that I want to modify appears there "You have not signed up.... In the table's column named 'url' it shows (in the row of the text in question) /pages/login.html.

     

    I've looked around the main script folder for a 'pages' folder without success. Are later versions of php structured to only change text in a related db table? That would be new to me. If so, what is an easy way to modify text there? Or, if there is a 'pages' folder somewhere in the main script folder, is there an easy way to search that main folder for /pages/.. ?

    Thanks for any help/enlightenment.

     

  2. I am looking getting a PHP script who's requirements list is:

     

    php GD module;

    php EXIF module;

    php CURL module;

    FFMPEG must be installed with libx264 codec.

    The php function exec() must be enabled on the server

    PHP7

     

    but I am told that maybe ffmpeg and php7 aren't compatible. Is that true? If so, what's with this companies' requirements list? Any ideas?

  3. Thanks for your message.

     

    Here is the uploadDrop.php code:

    <?php
    $ds          = DIRECTORY_SEPARATOR;
    $storeFolder = 'uploadDrop';
    if (!empty($_FILES)) {
        $tempFile = $_FILES['file']['tmp_name'];
        $targetPath = dirname( __FILE__ ) . $ds. $storeFolder . $ds;
        $targetFile =  $targetPath. $_FILES['file']['name'];
        move_uploaded_file($tempFile,$targetFile);
    }
    ?>
    

    Any additional help will be appreciated.

  4. I'm using dropzone js successfully to upload files from a web page.
    However, if a file gets uploaded that has the same name as a file already in the destination folder, it will overwrite the existing folder file.

    I tried to remedy this by adding the js script function as shown below, but it didn't work:

    <div id="dropzone">
    <form action="/uploadDrop.php" class="dropzone"></form>
    </div>
     
    <script type="text/javascript">
    Dropzone.autoDiscover = false;
    $(document).ready(function () {
        $(".dropzone").dropzone({
            renameFilename: function (filename) {
                return new Date().getTime() + '_' + filename;
            }
        });
    });
    </script>
    

    Any help with this will be appreciated.

     

  5. If you're familiar with dropzonejs maybe you can help me.
     
    The dropzone upload script I've installed uploads files successfully.
     
    I just want to change the max file size of the upload.
    It's default appears to be 256. I changed
    maxFilesize: from 256 to 20, in /dist/dropzone.js
     
    and then proceeded to test by uploading a 25MB file,
    which uploaded successfully, so, it appears that the maxFilesize still isn't limiting the upload file size to 20MB ?
     
    Any suggestions will be welcomed.
     
  6. The web cam recorder script that I'm working with has the "navigator', etc. code and the end of the script as shown below.
     
    I tried to add this code, so people trying to use the webcam recorder in IE will see an alert dialog box(without success):
     
    		    if (!navigator || !navigator.getUserMedia || !navigator.mediaDevices.getUserMedia) {
    		           if (window.confirm('Your browser does not support WebVideo, try Google/Chrome'))
    		    	   {
    		    window.location.href='https://../index.php';
    		    		} else {
    		    		    show();
    }
    }
    

    Maybe I've got something wrong. The window.confirm message still doesn't display in IE. Here's the script without the 'alert' code:

                    <script>
    		             const video = document.querySelector('video')
    		             const startvideo = document.querySelector('.start')
    		             const stopvideo = document.querySelector('.stop')
    		             const upload = document.querySelector('.upload')
    		             const initRecorder = stream => {
    		             const recorder = new MediaRecorder(stream)
    		             let blob
    		               video.srcObject = stream
    		               startvideo.removeAttribute('disabled')
    		               video.addEventListener('loadedmetadata', () => {
    		               video.play()
    		               })
    		               recorder.addEventListener('dataavailable', ({ data }) => {
    		               video.srcObject = null
    		               video.src = URL.createObjectURL(data)
    		               // Create a blob from the data for upload
    		               blob = new Blob([data], { type: 'video/webm' })
    		               })
    		 
    		               startvideo.addEventListener('click', () => {
    		               stopvideo.removeAttribute('disabled')
    		               show()
    		               reset()
    		               start()
    		               recorder.start()
    		 
    		 etc., etc, ............................
    		 
    		               navigator
    		                 .mediaDevices
    		                 .getUserMedia({ video: true })
    		                 .then(initRecorder)
    		                 .catch(console.error)
    		 
             </script>
    
    Any suggestions/enlightenment to get the 'alert'/confirm code to work with this script, will be appreciated.
  7. Thanks for your reply.

     

    This web cam recorder script that I'm working with now performs uploads successfully, however, it is the same file name every time it uploads. I've added in some 'generate random file name' code (with ////// surrounding it below), but it doesn't tie in with the working code. Any help/guidance/remedy will be welcomed.

    const video = document.querySelector('video')
    const start = document.querySelector('.start')
    const stop = document.querySelector('.stop')
    const upload = document.querySelector('.upload')
    
    const initRecorder = stream => {
    const recorder = new MediaRecorder(stream)
    
      let blob
    
      video.srcObject = stream
      start.removeAttribute('disabled')
    
      video.addEventListener('loadedmetadata', () => {
        video.play()
      })
    
      recorder.addEventListener('dataavailable', ({ data }) => {
        video.srcObject = null
        video.src = URL.createObjectURL(data)
    
        // Create a blob from the data for upload
        blob = new Blob([data], { type: 'video/webm' })
      })
    
      start.addEventListener('click', () => {
        stop.removeAttribute('disabled')
        recorder.start()
      })
    
      stop.addEventListener('click', () => {
        upload.removeAttribute('disabled')
        recorder.stop()
      })
    
    
      // Upload the video blob as form data 
          upload.addEventListener('click', () => {
          uploadBlob(blob)
    
        })
    
      }
    
    
    /////////////////////////////////////////////////////////////////////////////////////
    
       // this function is used to generate random file name
              function getFileName(fileExtension) {
                  var d = new Date();
                  var year = d.getUTCFullYear();
                  var month = d.getUTCMonth();
                  var date = d.getUTCDate();
                  return 'RecordRTC-' + year + month + date + '-' + getRandomString() + '.' + fileExtension;
              }
    
              function getRandomString() {
                  if (window.crypto && window.crypto.getRandomValues && navigator.userAgent.indexOf('Safari') === -1) {
                      var a = window.crypto.getRandomValues(new Uint32Array(3)),
                          token = '';
                      for (var i = 0, l = a.length; i < l; i++) {
                          token += a[i].toString(36);
                      }
                      return token;
                  } else {
                      return (Math.random() * new Date().getTime()).toString(36).replace(/\./g, '');
                  }
            }
    
    
    //////////////////////////////////////////////////////////////////////////////////////
    
      function uploadBlob(blob) {
          var formData = new FormData();
          formData.append('video-blob', blob);
          formData.append('video-filename', 'myvideo.webm');
          $.ajax({
              url: "upload.php",
              type: "POST",
              data: formData,
              processData: false,
              contentType: false,
    
                        success: function(response) {
    		                alert('Successfully uploaded.');
              },
    
              error: function(jqXHR, textStatus, errorMessage) {
                  alert('Error:' + JSON.stringify(errorMessage));
              }
          });
      }
    
    
      navigator
        .mediaDevices
        .getUserMedia({ video: true })
        .then(initRecorder)
        .catch(console.error)
    
  8. I have a  webcam script that works successfully on the web page. It starts, records, stops, and plays back successfully,
     
    But my Upload portion of the code needs help.
     
    Can you help me with uploading any recorded file to a (php) folder?
     
    Here's the javascript code:
     
    <script>
    const video = document.querySelector('video')
    const start = document.querySelector('.start')
    const stop = document.querySelector('.stop')
    const upload = document.querySelector('.upload')
    
    const initRecorder = stream => {
    const recorder = new MediaRecorder(stream)
    
      let blob
    
      video.srcObject = stream
      start.removeAttribute('disabled')
    
      video.addEventListener('loadedmetadata', () => {
        video.play()
      })
    
      recorder.addEventListener('dataavailable', ({ data }) => {
        video.srcObject = null
        video.src = URL.createObjectURL(data)
    
        // Create a blob from the data for upload
        blob = new Blob([data], { type: 'video/webm' })
      })
    
      start.addEventListener('click', () => {
        stop.removeAttribute('disabled')
        recorder.start()
      })
    
      stop.addEventListener('click', () => {
        upload.removeAttribute('disabled')
        recorder.stop()
      })
    
      // Upload the video blob as form data
      upload.addEventListener('click', () => {
        const body = new FormData()
    
        body.append('myvideo', blob)
    
        fetch('upload.php', { method: 'POST', body })
          .then(() => console.log('Success!'))
          .catch(console.error)
    
      })
    
      $myVideo = $_FILES['myvideo'];
    
      move_uploaded_file(
        $myVideo['tmp_name'],
        '../uploads/' . basename($myVideo['name'])
    );
    
    }
    
    navigator
      .mediaDevices
      .getUserMedia({ video: true })
      .then(initRecorder)
      .catch(console.error)
    
      </script>
    

    Any help will be welcomed

     

     

  9. The WebRTC/RecordRTC script that I'm using (here's where I got the script: https://www.webrtc-experiment.com/RecordRTC/)
    is functioning successfully(start record, stop record, upload). 
     
    But, I'm trying to have the script first show the webcam-view upon page load. 
     
    Currently it shows: image1 (attached). 
     
    The webcam-view currently only appears upon selecting 'Start Recording' button.
     
    So, I'd like the webcam-view to appear first upon page load (example - image2)
     
    Any help will be appreciated.
     
    Here's my current code:
     
    <!DOCTYPE html>
    <html>
    <head>
        <title>Video Recording | RecordRTC</title>
        <script src="https://cdn.webrtc-experiment.com/RecordRTC.js"></script>
        <script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>
    </head>
    
    <body>
        <style>
            html,
            body {
                margin: 0!important;
                padding: 0!important;
                overflow: hidden!important;
                width: 100%;
            }
        </style>
                    <style>
    		            video {
    		              max-width: 100%;
    		              border: 5px solid yellow;
    		              border-radius: 9px;
    		              width: 680px;
    		              height: 420px;
    		            }
    		            body {
    		              background: ffffff;
    		            }
    		            h1 {
    		              color: #800000;
    		            }
            </style>
    
       <header id="header"></header>
        <h1>Webcam Record</h1>
    
        <br>
    
        <button id="btn-start-recording">Start Recording</button>
        <button id="btn-stop-recording" disabled>Stop Recording</button>
        <button id="upload-video" onclick="InitUploading()" disabled="">Upload Now</button>
    
        <br>
     <video id="" controls="" autoplay=""></video>
    
    <script type="text/javascript">
    var video = document.querySelector('video');
    
            function captureCamera(callback) {
                navigator.mediaDevices.getUserMedia({
                    audio: true,
                    video: true
                }).then(function (camera) {
                    callback(camera);
                }).catch(function (error) {
                    alert('Unable to capture your camera. Please check console logs.');
                    console.error(error);
                });
            }
    
            function stopRecordingCallback() {
                video.src = video.srcObject = null;
                video.src = URL.createObjectURL(recorder.getBlob());
                PrepareBlob();
                document.getElementById("upload-video").disabled = false;
    
                // release camera
                recorder.camera.getTracks().forEach(function (track) {
                    track.stop();
                });
    
                recorder.camera.stop();
                recorder.destroy();
                recorder = null;
            }
            var recorder; // globally accessible
            document.getElementById('btn-start-recording').onclick = function () {
                this.disabled = true;
                document.getElementById("upload-video").disabled = true;
                captureCamera(function (camera) {
                    setSrcObject(camera, video);
                    video.play();
                    recorder = RecordRTC(camera, {
                        type: 'video'
                    });
                    recorder.startRecording();
                    // release camera on stopRecording
                    recorder.camera = camera;
                    document.getElementById('btn-stop-recording').disabled = false;
                });
            };
            document.getElementById('btn-stop-recording').onclick = function () {
                this.disabled = true;
                document.getElementById('btn-start-recording').disabled = false;
                recorder.stopRecording(stopRecordingCallback);
            };
            var blob, fileName, fileObject;
            function PrepareBlob() {
                // get recorded blob
                blob = recorder.getBlob();
                // generating a random file name
                fileName = getFileName('webm');
                // we need to upload "File" --- not "Blob"
                fileObject = new File([blob], fileName, {
                    type: 'video/webm'
                });
            }
            function InitUploading()
            {
                uploadToPHPServer(fileObject, function (response, fileDownloadURL) {
                    if (response !== 'ended') {
                        document.getElementById('header').innerHTML = response; // upload progress
                        return;
                    }
    
    		document.getElementById('header').innerHTML = '<a href="' + fileDownloadURL + '" target="_blank">' + fileDownloadURL + '</a>';
    		alert('Successfully uploaded recorded blob.');
    
                    alert('Successfully uploaded recorded blob.');
                    // preview uploaded file
                    video.src = fileDownloadURL;
                    // open uploaded file in a new tab
                    window.open(fileDownloadURL);
                });
            }
    
            function uploadToPHPServer(blob, callback) {
                // create FormData
                var formData = new FormData();
                formData.append('video-filename', blob.name);
                formData.append('video-blob', blob);
                callback('Uploading recorded-file to server.');
                makeXMLHttpRequest('save.php', formData, function (progress) {
                    if (progress !== 'upload-ended') {
                        callback(progress);
                        return;
                    }
                    var initialURL = 'uploads/' + blob.name;
                    callback('ended', initialURL);
                });
            }
    
            function makeXMLHttpRequest(url, data, callback) {
                var request = new XMLHttpRequest();
                request.onreadystatechange = function () {
                    if (request.readyState == 4 && request.status == 200) {
                        if (request.responseText === 'success') {
                            callback('Upload Complete');
                            return;
                        }
                       // alert(request.responseText);
                            window.location.href = '/index.com/';
                        return;
                    }
                };
                request.upload.onloadstart = function () {
                    callback('Upload started...');
                };
                request.upload.onprogress = function (event) {
                    callback('Upload Progress ' + Math.round(event.loaded / event.total * 100) + "%");
                };
                request.upload.onload = function () {
                    callback('Progress Ending');
                };
                request.upload.onload = function () {
                    callback('Upload Complete');
                };
                request.upload.onerror = function (error) {
                    callback('Upload failed.');
                };
                request.upload.onabort = function (error) {
                    callback('Upload aborted.');
                };
                request.open('POST', url);
                request.send(data);
            }
            // this function is used to generate random file name
            function getFileName(fileExtension) {
                var d = new Date();
                var year = d.getUTCFullYear();
                var month = d.getUTCMonth();
                var date = d.getUTCDate();
                return 'RecordRTC-' + year + month + date + '-' + getRandomString() + '.' + fileExtension;
            }
    
            function getRandomString() {
                if (window.crypto && window.crypto.getRandomValues && navigator.userAgent.indexOf('Safari') === -1) {
                    var a = window.crypto.getRandomValues(new Uint32Array(3)),
                        token = '';
                    for (var i = 0, l = a.length; i < l; i++) {
                        token += a[i].toString(36);
                    }
                    return token;
                } else {
                    return (Math.random() * new Date().getTime()).toString(36).replace(/\./g, '');
                }
            }
        </script>
    </body>
    </html>
    

     

    post-20454-0-39222500-1507765419_thumb.png

    post-20454-0-91813200-1507765426_thumb.png

  10. Thanks for your reply.

    Regarding your reply a) can you gove me an example of what you're refering to? I'm note clear on that.

     

    I have now replaced this:

    // Allow certain file formats
    if($imageFileType != "MP4" && $imageFileType != "MPEG4" && $imageFileType != "MOV"
    && $imageFileType != "OGG" && $imageFileType != "MKV") {
        echo "Sorry, only MPEG4, MP4 and MOV files are allowed.";
        $uploadOk = 0;
    }
    

    with this:

    $extensions= array("mov","mp4");
    if(in_array($file_ext,$extensions)=== false){
     $errors[]="File type not allowed, only MP4 or MOV files.";
    }
    

     And that seems to work successfully.

    If that's not what you mean regarding b) and c) I look forward to any additional guidance.

    Much thanks again

  11. I'm trying to upload a video from an android device, but I see this error:
    "Sorry, only MPEG4, MP4 and MOV files are allowed"
    Here's the code below (it works successfully via IOS).
     
    Any help/guidance suggestion will be appreciated.
     
    <html> 
    <head><title>Upload</title></head> 
    <body> 
    <form action="upload1.php method="post" enctype="multipart/form-data"> 
    Select image to upload: 
    <input type="file" name="fileToUpload" id="fileToUpload" accept="video/*" capture> 
    <input type="submit" value="Upload Image" name="submit"> 
    </form> 
    </body> 
    </html>
    
    <?php
    $target_dir = "uploads/";
    $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
    $uploadOk = 1;
    $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
    
    // Check if file already exists
    if (file_exists($target_file)) {
        echo "Sorry, file already exists.";
        $uploadOk = 0;
    }
    // Check file size
    if ($_FILES["fileToUpload"]["size"] > 50000000) {
        echo "Sorry, your file is too large.";
        $uploadOk = 0;
    }
    // Allow certain file formats
    if($imageFileType != "MP4" && $imageFileType != "MPEG4" && $imageFileType != "MOV"
    && $imageFileType != "OGG" && $imageFileType != "MKV") {
        echo "Sorry, only MPEG4, MP4 and MOV files are allowed.";
        $uploadOk = 0;
    }
    // Check if $uploadOk is set to 0 by an error
    if ($uploadOk == 0) {
        echo "Sorry, your file was not uploaded.";
    // if everything is ok, try to upload file
    } else {
        if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
        header ("location: ThankYou.html");
    return;
    
           // echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
        } else {
            echo "Sorry, there was an error uploading your file.";
        }
    }
    ?>
    

     

  12. After running this, trying to upload a video from a mobile phone, I apparently don't have the php set for video?

    Because I am unsuccessful in uploading and the message I see after attempting (from mobile phone) is:

    "File is not a video Sorry, your file was not uploaded."

     

    Any help/guidance suggestion will be appreciated.

    Here's the code:

    <html> 
    <head><title>Upload</title></head> 
    <body> 
    <form action="upload1.php method="post" enctype="multipart/form-data"> 
    Select image to upload: 
    <input type="file" name="fileToUpload" id="fileToUpload" accept="video/*" capture> 
    <input type="submit" value="Upload Image" name="submit"> 
    </form> 
    </body> 
    </html>

    And here is upload1.php code:

    <?php
    $target_dir = "uploads/";
    $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
    $uploadOk = 1;
    $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
    // Check if image file is a actual image or fake image
    if(isset($_POST["submit"])) {
        $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
        if($check !== false) {
            echo "File is an image - " . $check["mime"] . ".";
            $uploadOk = 1;
        } else {
            echo "File is not a video";
            $uploadOk = 0;
        }
    }
    // Check if file already exists
    if (file_exists($target_file)) {
        echo "Sorry, file already exists.";
        $uploadOk = 0;
    }
    // Check file size
    if ($_FILES["fileToUpload"]["size"] > 50000000) {
        echo "Sorry, your file is too large.";
        $uploadOk = 0;
    }
    // Allow certain file formats
    if($imageFileType != "MP4" && $imageFileType != "MPEG4" && $imageFileType != "MOV"
    && $imageFileType != "OGG" ) {
        echo "Sorry, only MPEG4 & MP4 files are allowed.";
        $uploadOk = 0;
    }
    // Check if $uploadOk is set to 0 by an error
    if ($uploadOk == 0) {
        echo "Sorry, your file was not uploaded.";
    // if everything is ok, try to upload file
    } else {
        if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
            echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
        } else {
            echo "Sorry, there was an error uploading your file.";
        }
    }
    ?>
    
  13. I have this Upload Form that uploads a file successfully,
    and sends the info from the Name-form-field and the Email-form-field successfully.
    But nothing arrives from the Message-form-field. Here's the code:
     
    <?php
    session_start();
    require_once 'phps3integration_lib.php';
    $message = "";
    $message1= "";
    if (@$_POST['submit'] != "") {
    $allowed_ext = array("gif", "jpeg", "jpg", "png", "pdf", "doc", "docs", "zip", "mov", "MOV", "flv", "mp4", "3gp", "3GP");
    $extension = end(explode(".", $_FILES["file"]["name"]));
    if (($_FILES["file"]["size"] < 104857600) && 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 {
    $uploaddir = '../Upload/';
    $uploadfile = $uploaddir . basename($_FILES['file']['name']);
    $uploaded_file = false;
    if(move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile))
    {
    $uploaded_file = $_FILES['file']['name'];
    }
     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'
    );
    
    if(empty($_POST['agree']) || $_POST['agree'] != 'agree') {
    $message1.= "Please read and agree to the Terms and Conditions To Proceed With Upload";
    };
    
    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.= "Invalid file, Please upload a gif/jpeg/jpg/png/pdf/doc/docs/zip/mov/flv/mp4/3gp file of maximum size 25 MB.";
    }
    }
    
     if ($_SERVER['REQUEST_METHOD'] === 'POST') {
            $email_to = "[email protected]";
    	    $email_subject = "From FORM";
    	    $message = $_POST['message'];
    	    $name = $_POST['name'];
    	    $email = $_POST['email'];
    
    	$headers = "From: $email \r\n";
        $sent = mail($email_to,$email_subject,$message,$headers);
    }
    
    
    ?>
    
    <?php
    require_once 'header.php';
    ?>
    <head>
    
    <script>
    var ids = ['input', 'message', 'button'];
    var obj = {};
    
    ids.forEach(function (v) {
        obj[v] = document.getElementById(v);
    });
    
    obj.input.style.display = 'none';
    obj.button.style.display = 'block';
    
    obj.input.addEventListener('change', function () {
        obj.message.innerText = this.value;
        obj.message.style.display = 'block';
    });
    
    obj.button.addEventListener('click', function (e) {
        e.preventDefault();
    
        obj.input.click();
    });
    </script>
    
    </head>
    <html>
    <div id="genericUp">
    <br /><br /><br /><br />
    <font size="6" color="#84786e"><b>Upload</b></font><br /><br />
    
    <fieldset>
    <form action="" method="post" enctype="multipart/form-data" onsubmit="if(document.getElementById('agree').checked) { return true; } else { alert('Please indicate that you have read and agree to the Terms by selecting the checkbox'); return false; }">
    
    <div class="control-group">
    <label for="file" class="control-label"><font size="6" color="#454545"><b>Choose a file to upload:</b></font></label><br /><br />
    
    <!--<div class='controls'>-->
    <input id="input" name="file" type="file" /></input>
    <button id="button"><font size="3" color="#454545">Click To<br /> Select File</font></button>
    <div id="message"><font size="3" color="#454545">No File Chosen</font></div>
    </div>
    <div>
    <br />
    <input class="form-control" type="text" name="name" maxlength="50" style="width:250px; height:20px; background-color:transparent; float:left; padding:0px 0px 0px 10px; margin:0px 0px 5px 0px; font-family: helvetica;
    font-size: 12px; color:#cccccc; border:1px solid #cccccc"; placeholder="Name">
    <br /><br />
    </div>
    <div>
    <input class="form-control" type="text" name="email" maxlength="50" style="width:250px; height:20px; background-color:transparent; float:left; padding:0px 0px 0px 10px; margin:0px 0px 5px 0px; font-family: helvetica;
    font-size: 12px; color:#cccccc; border:1px solid #cccccc"; placeholder="Email">
    <br /><br />
    </div>
    <textarea id="message4"  name="message" maxlength="70" cols="25" rows="6"></textarea>
    <br /><br />
    </div>
    <div>
    <input type="checkbox" name="checkbox" value="check" id="agree" vertical-align:top;/> By uploading a file you agree to these
    <a href="../Terms.php" target="_blank"><font size="2" color="#000000" face="Arial"><u>Upload Terms/Agreement</u></a></font></label>
    </div>
    
    <br />
    <div class="control-group">
    <div class='controls'>
    <label class="myLabel1">
    <input type="submit" name="submit" value="Submit" class="btn" style="opacity: 0"><br /><br />
    </label><br /><br />
    </div>
    </form>
    </fieldset>
    
    <script>
    var ids = ['input', 'message', 'button'];
    var obj = {};
    
    ids.forEach(function (v) {
        obj[v] = document.getElementById(v);
    });
    
    obj.input.style.display = 'none';
    obj.button.style.display = 'inline-block';
    
    obj.input.addEventListener('change', function () {
        var filename = this.value.replace(/^.*[\\\/]/, '');
    		obj.message.innerHTML  = filename;
        obj.message.style.display = 'inline-block';
    });
    
    obj.button.addEventListener('click', function (e) {
        e.preventDefault();
    
        obj.input.click();
    });
    </script>
    <?php
    if ($message != "" || @$_SESSION['message'] != "") {
        ?>
        <div class="alert alert-success">
        <?php echo $message; ?>     
        <?php
        echo @$_SESSION['message'];
        @$_SESSION['message'] = '';
        ?>
        </div>
        <?php
    }
    ?>
    <div>
    </div>
    </div>
    

    Any help with getting what is entered into the Message field to be sent/delivered will be appreciated.

     

  14. I'm using an upload script (I did not write it) that works successfully.

     

    I'm trying to add the function where you 'must check box to agree to terms' prior to uploading a file.

     

    I've added lines 67 thru 75, and lines 88 thru 92, but it is missing something, because, whether the box is checked or not, a file can still be uploaded.

     

    Any guidance 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", "mov", "MOV", "flv", "mp4", "3gp", "3GP");
    $extension = end(explode(".", $_FILES["file"]["name"]));
    if (($_FILES["file"]["size"] < 10485760000) && 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 {
    $uploaddir = '../Upload/';
    $uploadfile = $uploaddir . basename($_FILES['file']['name']);
    $uploaded_file = false;
    if(move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile))
    {
    $uploaded_file = $_FILES['file']['name'];
    }
    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.= "Invalid file, Please upload a gif/jpeg/jpg/png/pdf/doc/docs/zip/mov/flv/mp4/3gp file of maximum size 25 MB.";
    }
    }
    ?>
    
    <?php
    require_once 'header.php';
    ?>
    <head>
    
    <script>
    var ids = ['input', 'message', 'button'];
    var obj = {};
    
    ids.forEach(function (v) {
        obj[v] = document.getElementById(v);
    });
    
    obj.input.style.display = 'none';
    obj.button.style.display = 'block';
    
    obj.input.addEventListener('change', function () {
        obj.message.innerText = this.value;
        obj.message.style.display = 'block';
    });
    
    obj.button.addEventListener('click', function (e) {
        e.preventDefault();
    
        obj.input.click();
    });
    </script>
    
    <script type="text/javascript">
    function validate()
    {
    if(false == document.getElementById("agree").checked)
    {
    alert("If you agree with the terms, check the Agree check box");
    }
    }
    </script>
    
    </head>
    <html>
    <fieldset>
    <form action="" 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><br /><br />
    <input id="input" name="file" type="file" /></input>
    <button id="button"><font size="3" color="#454545">Click To<br /> Select File</font></button>
    <div id="message"><font size="3" color="#454545">No File Chosen</font></div>
    </div>
    <div>
    <input type="checkbox" name="agree" id="agree" value="agree" /> <label for='agree'>
    <a href="../Terms1.php" target="_blank"><span style="color: #454545; font-size: 10px">By uploading a file here, you agree to these <u>Upload Terms/Agreement</u></a></span>
    </label>
    </div>
    <div class="control-group">
    <div class='controls'>
    <label class="myLabel1">
    <input type="submit" name="submit" value="Submit" class="btn" style="opacity: 0">
    </label><
    </div>
    </form>
    </fieldset>
    
    <script>
    var ids = ['input', 'message', 'button'];
    var obj = {};
    
    ids.forEach(function (v) {
        obj[v] = document.getElementById(v);
    });
    
    obj.input.style.display = 'none';
    obj.button.style.display = 'inline-block';
    
    obj.input.addEventListener('change', function () {
        var filename = this.value.replace(/^.*[\\\/]/, '');
    		obj.message.innerHTML  = filename;
        obj.message.style.display = 'inline-block';
    });
    
    obj.button.addEventListener('click', function (e) {
        e.preventDefault();
    
        obj.input.click();
    });
    
    </script>
    <?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'; ?>
    
    
    
  15. Thanks for your replies.

     

    Regarding "show us the code", I have showed the php in the intial posting, and here is the Form:

    <form action='../ContactForm.php' method='post' name='myform' onSubmit="return checkemail()">
    <div class="row">
    <div class="col-sm-4">
    <input class="form-control" type="text" name='contact_name' placeholder="Name">
    </div>
    <div class="col-sm-4">
    <input class="form-control" type="text" name='email_address' placeholder="Email">
    </div>
    </div>
    <br>
    <div class="row">
    <div class="col-sm-12">
    <textarea name='Description' placeholder="Type your message here..." class="form-control" rows="9"></textarea>
    </div>
    </div>
    <div class="row">
    <div class="col-sm-4">
    <p style="color:grey; font-size:15px;"><b>Security Question:<br> Is Fire Hot Or Cold?:</p>
    <input type="text" name="ans"/><br>
    <div>
    <div class="row">
    <div class="col-sm-4">
    <input class="btn btn-action" type='submit' value="Send message">
    </div>
    </div>
    </div>
    </form>
    

    Regarding "Can you assign a header call to a variable?", I'm not clear on that. Is my url(s) the variable?

    Any clarification, and/or code tweak suggestion will be greatly appreciated.

  16. Thanks so much for your reply.

    Yes, I have this input field:

    <input type="text" name="ans"/>
    

    which works successfully from my windows desktop. After entering 'hot' and select 'Send Message' I am successfully directed to the page(I've changed the url for this posting) listed here"

    // if no errors are set, continue
    if(empty($error))
    {
    header('Location: ww.somesite.com/ThankYou.html');
    exit;
    }
    

    And also, from my desktop if I enter anything other than 'hot', and select 'Send Message', I'm successfully directed to the page listed here:

    $error[] = header('Location: ww.somesite.com/WrongAnswer.html');
    exit;
    

    But from my iPhone when I enter 'hot' (or anything else) and select either 'Send Message", Done(on the phone) and then 'Send Message', or 'Go'(on the phone), no matter what, I'm directed to this page:

    ww.somesite.com/WrongAnswer.html
    

    So, if it's true that "Entering text on a mobile is no different than a fixed desktop", than obviously and not surprisingly, my code needs some type of correction/modification.

     

    Any ideas/suggestions will be appreciated.

    Much thanks again

  17. I realize this is old code (that I didn't write) but works well for a temporary 'under construction' page.
    After filling in the simple Form fields the simple Security question is presented : Is fire Hot or Cold?
    When I enter text into the answer field it works successfully, except, of course on a mobile device. In order for it to work on a mobile device, I believe I need to present a choice, rather than entering text - correct?
    So, I'm looking for a possible simple tweak on this code, so that it will work for a mobile device, please. I don't really want to re-write all of it, and I know it's not super-secure, but it will do for now.
     
    Here's the last part of the Form:
     
    <div>
    <p>Security Question:<br> Is Fire Hot Or Cold?:
    <input type="text" name="ans"/></p><br>
    <p><input class="btn btn-action" type='submit' value="Send message"></p>
    </div>
    </form>
    
    And
     
    
    <?php
    // create an empty error array to hold any error messages\
    $error = array();
    $mailto     = '[email protected]';
    $mailsubj   = "ContactForm Submission";
    $mailhead   = "From:SomehereForm\n";
    $mailbody   = "--- Contact form results ---\n";
    foreach($_REQUEST as $key => $value)
    {
    if($key != 'PHPSESSID')
    {
    $mailbody .= $key.": ".$value."\n";
    }
    }
    if(isset($_POST['ans']) && $_POST['ans']!='hot')
    {
    // add error to error array
    $error[] = header('Location: ww.somesite.com/WrongAnswer.html');
    exit;
    }
    // if no errors are set, continue
    if(empty($error))
    {
    header('Location: ww.somesite.com/ThankYou.html');
    exit;
    }
    ?>
    

    Is it possible to add something like:

    <option value="ans">hot</option>
    <option value="">cold</option>
    

    and then change this somehow:

    $error['anything other than hot'] = header('Location: ww.somesite.com/WrongAnswer.html');
    exit;
    

    Any tweak help will be appreciated.

  18. Thanks for your reply.

     

    I saw this on a Support Forum (i'm not sure if it pertains to this) It said this:

    "If you already have your parameters set like $_POST['eg'] for example and you don't wish to change it, simply do it like this:

    $_POST = json_decode(file_get_contents('php://input'), true);
    

    This will save you the hassle of changing all $_POST to something else and allow you to still make normal post requests."

     

    Would that work in my situation?

  19. Thanks again for your reply.

     

    Here's the Form:

    		<form id="ajax-contact" method="post">
            <table class="table10">
            <tr>
            <td colspan="3"><textarea id="contact-message" placeholder="MESSAGE:" required/></textarea>
            </td>
    		<tr>
    		<td>
            <input id="contact-name" name="name" value="NAME" onfocus="if (this.value=='NAME') {this.value=''; this.style.color='#000000';}" onclick="clickclear(this, 'Enter Name')" onblur="clickrecall(this,'')" required/>
            </td>
    		<td>
            <input id="contact-email1" name="email" value="EMAIL" onfocus="if (this.value=='EMAIL') {this.value=''; this.style.color='#696969';}" required/>
            </td>
            <tr>
    		<td class="captcha">
    		ENTER IMAGE TEXT:  <input name="captcha" style="width:100px" type="text" required/>  <img src="captcha.php" />
    		</td>
    		<td>
            <input type="hidden" name="submit" ><input class="my-input1" type="submit" value="SEND">
            </td>
            </tr>
            </table>
    		</form>
    
  20. Thanks for your reply.

    But, I'm not clear on what you're asking for. Is it this?:

    <?php
    session_start();
    $code=rand(1000,9999);
    $_SESSION["code"]=$code;
    $im = imagecreatetruecolor(80, 24);
    $bg = imagecolorallocate($im, 177, 78, 78);
    $fg = imagecolorallocate($im, 255, 255, 255);
    imagefill($im, 0, 0, $bg);
    imagestring($im, 5, 24, 3,  $code, $fg);
    header("Cache-Control: no-cache, must-revalidate");
    header('Content-type: image/png');
    imagepng($im);
    imagedestroy($im);
    ?>
    
  21. I merged this code from a captcha script:

     

    <?php
    session_start();
    if(isset($_POST["captcha"])&&$_POST["captcha"]!=""&&$_SESSION["code"]==$_POST["captcha"])
    {
    echo "Correct Code Entered";
    //Do your stuff
    }
    else
    {
    die("Wrong Code Entered");
    }
    ?>
    

    with a working Contact Form script code:

    <?php
    $data = json_decode(file_get_contents("php://input"));
    $name = trim($data->name);
    $name = str_replace(array("\r", "\n"), array(" ", " "), $name);
    $email = filter_var(trim($data->email), FILTER_SANITIZE_EMAIL);
    $message = trim($data->message);
    // Check that data was sent.
    if (empty($name) || empty($message) || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
    echo "One or more invalid entries. Please try again.";
    exit;
    }
    
    $to = "[email protected]";
    $from = "From: [email protected]". "\r\n";
    $body = "A message has been sent via the website contact form.\n\n";
    $body .= "Name: $name\n";
    $body .= "Email: $email\n\n";
    $body .= "Message:\n$message\n";
    
    if (mail($to, 'Customer Inquiry', $body)){
    echo "Thank You. Your Message Has Been Sent.";
    } else {
    echo "An error has occurred and your message could not be sent.";
    }
    ?>
    

    to get this:

    <?php
    	session_start();
    	
    	$data = json_decode(file_get_contents("php://input"));
    	$name = trim($data->name);
    	$name = str_replace(array("\r", "\n"), array(" ", " "), $name);
    	$email = filter_var(trim($data->email), FILTER_SANITIZE_EMAIL);
    	$message = trim($data->message);
    	// Check that data was sent.
    	if (empty($name) || empty($message) || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
    	echo "One or more invalid entries. Please try again.";
    	exit;
    	}
    	
    	if(isset($_POST["captcha"])&&$_POST["captcha"]!=""&&$_SESSION["code"]==$_POST["captcha"])
    	{
    	echo "Correct Code Entered";
    	//Do your stuff
    	}
    	else
    	{
    	die("Wrong Code Entered");
    	}
    	
    	$to = "[email protected]";
    	$from = "From: [email protected]". "\r\n";
    	$body = "A message has been sent via the website contact form.\n\n";
    	$body .= "Name: $name\n";
    	$body .= "Email: $email\n\n";
    	$body .= "Message:\n$message\n";
    	
    	if (mail($to, 'Customer Inquiry', $body)){
    	echo "Thank You. Your Message Has Been Sent.";
    	} else {
    	echo "An error has occurred and your message could not be sent.";
    	}
    ?>
    

    but after I tested/completed the Form, including entering the correct Captcha code, I see the message "Wrong Code Entered", and of course the Contact Form info does not send.

     

    I added this (after the 'session start' line):

    var_dump($_SESSION);
    

    and ran the Form, and I see this:

    array(2) { ["security_code"]=> string(6) "9569qb" ["code"]=> int(6133) } Wrong Code Entered
    

    Any guidance with integrating captcha script successfuly will be appreciated.

  22. I have this Contact Form, that I'm trying to add a captcha element to it. The captcha script html part is this:

    <td>
    Enter Image Text<input name="captcha" type="text"><img src="captcha.php" />
    </td>
    

    And it looks like (see attached image)

     

    How can I style this, and also put some space between the text, the field box, and the numbers box, horizontally?

     

    I look forward to some suggestions. Much thanks.

    post-20454-0-38721500-1477527601_thumb.png

  23. Thanks for your replies.

    This is not code that I wrote. Someone provided it to me and it seems like it's close to working.

    I'm not familiar with "superglobal $_PRINT".

    And I'm not clear on "put the contact data into the e-mail content", doesn't the Contact Form user enter the content into the Form fields?

    And additional guidance/examples, would be appreciated

×
×
  • 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.