Jump to content

phppup

Members
  • Posts

    862
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by phppup

  1. Anybody have any recommendations for a web-hosting provider that will offer PHP, SQL, email, and other assorted features that would be beneficial (like the ability to run CRON jobs, etc.)?

    @ginerjm I noticed in a recent thread that you cautioned against GoDaddy. Who would you suggest as an alternative?

  2. @ginerjm 

    Quote

    I would NEVER use W3 as a resource.

    That's good to know, but they come up on top of many searches and you failed to offer any constructive alternative as a recommendation.  Should I use nothing at all!!?!

     

    @mac_gyver Thanks for the helpful information.

    Much appreciated.

    PS: So, if I'm digesting this properly (and I do agree with your methodology) a value should NOT be subjected to htmlentities/htmlspecialchars UNLESS being used within an HTML context.  Tinkering with the value, even as a variable going into a database is essentially unnecessary?

     

  3. I need a little clarity, as I have a form with input and want to sanitize the input effectively to avoid attacks and complications.

    I adapted a W3 example but got unexpected results when I tried to view the results to verify success.

    
      $data = trim($data);             echo "after trim >".$data."<br>";
      $data = stripslashes($data);     echo "after strip >".$data."<br>";
      $data = htmlspecialchars($data); echo "after char >".htmlspecialchars($data)."<br>";
    
      echo "straight ".htmlspecialchars($data)."<br>";  //different viewable result
    
      echo " >".$data."<br><br>";
      

    Is there something going on 'behind the scenes' that I'm not recalling.

    Please inform and advise for best practices.

    Thanks.

  4. Hey @mac_gyver , I want to thank you tremendously for your responses.

    After scrolling further in the tutorial that I was using I spotted a section that states EXACTLY what you mentioned above with an added caveat that there is an exception if

    Quote

    using the FormData object to send form data

    and it then provides the necessary JavaScript.

    I'm not sure why there's a difference, but at this point I'm just happy to have working components that suit my needs.

    Nonetheless, curiosity did have me wondering, would the solution that you provided initially have worked if I had used the "more traditional" AJAX format?

    And yes, I understand the need for validating and sanitizing form data (but thanks for the reminder) and was more concerned that the alternate method of JavaScripting might (in itself) open a vulnerability.

  5. @mac_gyver A follow-up to your solution (which initially failed).

    The AJAX road has been grimy for me, so this time around, instead of using the usual format of

            $.ajax({ 
            type: "POST", 
            url: "check.php", 
            data: "email="+ usr,
            dataType: 'text',
                success: function(msg){
                    if(msg == 'OK'){
                     alert ("success");
                    // ..... etc.

    I tried a format from W3 that looks like this

    function loadDoc() {
      const xhttp = new XMLHttpRequest();
      xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
          // ....blah blah blah

    I don't really know the difference between the two, but in building my script it seemed to be accomplishing the assigned task.

    I plugged in the code you provided, and then added some troubleshooting to determine that

    if(IS_AJAX_REQUEST)

    was determining a NO response.

    Ultimately, I modified your code and seem to have success with

    if($_SERVER["REQUEST_METHOD"] == "POST")
    {
        // build and output the response to the AJAX request
        // typeically json_encode([some meaningful error or success data]);
    echo "<br>yes AJAX request detected<br>"; die; } else { echo "<br>no AJAX request NOT detected<br>";
        // stopped php code execution in affirmative only
        
    }


    Now I have new questions (if you (or anyone else) would be so kind):

    Is my revision safe to use?

    Does it create any security issues or functional dilemmas?

    I can see why my code (built on your assistance) works, but why does the original not detect the AJAX submission as was expected?

  6. For simplicity, I've sometimes created a form with

    <form action="" method="POST">

    which had the form self-check its file to run PHP.

    Now I have a file with a form and I am using AJAX where the URL link is the same file.

    It didn't work with "" but does with the file name.

    However, because it is regurgitating the file, a by-product of the process is that the webpage displays the form twice.

    Is there a fix to stop this under these conditions. Or is an external PHP file the only solution?

  7. I can probably find this answer by implementing the appropriate code, but in the planning stages, I thought i'd ask the more advanced brethren.

    The plan: a form that includes an HTML textarea where a user can type a message.

    Upon submission, the form will be processed and the contents of the textarea will be POSTed into an email that will be sent using the PHP function.

    The question: if a user types (using the keyboard return key)

    H

    E

    L

    P

    into the textarea, will it be displayed with new lines within the email? Or will it become a single line string?

    Are there particular settings that can be made so that the email is a duplicate in the EXACT format of text that is entered into the form?

  8. RESOLVED.

    I couldn't find a CSS solution to having page 1 on the form "fade in" either initially or when coming BACK from page 2.

    However, I implemented a JavaScript function that is accomplishing the task.

  9. I somehow got hooked on a stylish form that was broken into stages that click thru three steps.

    It uses CSS and hidden checkboxes to activate an effect that has each section transition into a visible opacity (a fade-in effect).

    I was hoping to use the code as a template, but discovered that the FIRST page (which does not have an associated checkbox in the HTML) does not at any point "fade-in" (it just remains visible).

    This makes the entire form seem 'clumsy' bc the effect should occur with NEXT or PREVIOUS button clicks.

    I've included the pertinent code.

    I'm also not sure of whether or not using CSS is the best route for this. I'm sure JavaScript can do this; is one approach better than the other?

    Thanks.

    input[type=checkbox] {
    	position: absolute;
    	opacity: 0;
    }
    #part1, #part2, #part3 {
    	z-index: 2;
    	display: block;
    	height: auto;
    	opacity: 1;
    	transition: opacity 1s ease-in-out;
    }
    #part2, #part3 {
    	opacity: 0;
    	height: 0;
    	overflow: hidden;
    }
    #step2:checked ~ #part2 {
    	opacity: 1;
    	height: auto;
    }
    #step2:checked ~ #part1 {
    	opacity: 0;
    	height: 0;
    	display: none;
    }
    #step3:checked ~ #part3 {
    	opacity: 1;
    	height: auto;
    }
    #step3:checked ~ #part2 {
    	opacity: 0;
    	width: 0;
    	height: 0;
    }

     

     

  10. Quote

     'just have php return the status of the call' - add a boolean to the return payload that can tell the javascript if the php failed in a manner that didn't cause a server exception.

    That's a little deeper than I'm currently capable, and I don't really have the time to do the homework.

  11. Eureka!! I got it working.

    I set up a SELECT statement in PHP to echo a table when the script is called.

    The page never refreshed when using the form in AJAX, but when I refresh the page, it displays all entries made to the form by PHP.

    I suppose my only lingering question is, within this standard AJAX context

    jQuery.ajax({
    				url : "myPHPcode.php",
    				data : 'userName=' + $("#userName").val() + '&userEmail='
    						+ $("#userEmail").val() + '&subject='
    						+ $("#subject").val() + '&content=' + $(content).val(),
    				type : "POST",
    				success : function(data) {  ... do stuff

    where the final action is "success," is there a way to get confirmation of success of the PHP code?

    In other words, it seems that "success" will blow confetti simply because the JS got that far (regardless of PHP issues), but would it still trigger "success"  if the PHP file failed?

    If the PHP was designed to INSERT into a database, and the connection could not be made (therefore triggering an error in PHP/SQL), can a notification of the failure be given?

    From what I've experienced, I don't like the one-way street of this Asynchronous method   *humor*

    PS: what is the correct way to change my "data" section to a serialized method?

    I saw it mentioned, and it seems to offer more flexibility with less keystrokes, but I haven't been able to implement it.

    Thanks to everyone for helping.

  12. I suppose I'm used to having the webpage reload/advance when a submit button is clicked.

    I'm a bit lost in how my PHP is accessed when the data is submitted.

    My "nerve center" of AJAX is

    jQuery.ajax({
    				url : "myPHPcode.php",
    				data : 'userName=' + $("#userName").val() + '&userEmail='
    						+ $("#userEmail").val() + '&subject='
    						+ $("#subject").val() + '&content=' + $(content).val(),
    				type : "POST",
    				success : function(data) {  ... do stuff

    Is anything missing?

    Does it call the PHP file every time the submit button active (with all field valid)?

    Since the page doesn't reload, I'm not able to receive a PHP coded response.

    My PHP

    if(isset($_POST['submit'])){
    echo "success"; } else { echo "failed";
    }

    failed on load and never changes.

     

     

    Quote

     

  13. @requinix A confirmation (that will be removed from the script) that tells me that everything in development is working as expected to this this point.

    An assurance that if a problem occurs, I can essentially eliminate troubleshooting back to the form bc I'll have confirmed that the data is being sent and therefore development can move forward with confidence.

    Then, if, for instance, a table isn't being populated, I can limit my review to the PHP and SQL for bugs.

  14. I am trying to use a form that I found online. It is AMAZINGLY stylish (LOL) and presumably uses an AJAX implementation to integrate its jQuery features.

    Now that I've finally gotten most of the features to meet my liking, I want to confirm the transfer of data upon submitting.

    I read through the previous post jquery / javascript function return by Digger and realize the asynchronous impossibility of the task.

    So am I forced to go on faith now? Is there no way to confirm (from a PHP standpoint) that the data is being sent? 

    Is the only way of verifying my progress to create and insert into a table, and then select the data for a viable confirmation?

    I was expecting to just run a var_dump to confirm.

  15. Thanks for the info, but I may have gotten a better handle on this (versus my unconventional description of the effect I'm trying to duplicate).

    It seems that the CSS collapse effect make be more in line with my goal.

    I'm going to compare the different sample codes for slide, collapse, and JavaScript to find a solution that gives me a form that kinda unravels down/up over the existing page text via a toggle click.

     

  16. It's not really a problem as I think a slightly different effect.

    CSS seems to slide the entire form into place like moving a cracker from behind a box, and JQuery seems to 'unravel' like a paper towel roll that falls from a table.

    If necessary, I will try to post code when time permits.

     

  17. In playing with a contact form that will "slide down" from a given point in the webpage, and I've found two attractive methods.

    CSS seems to accomplish the affect with an animation that carries the contents of my form up and down depending on a toggle button.

    I found a similar effect using JQuery's slideDown("slow") or slideUp("slow").

    The JQuery seems like a smoother effect as it appears to 'unravel' but I am less comfortable with JQuery and connecting to outside libraries.

    Can this effect be duplicated more readily with CSS?

    Is there a simplified JQuery (or a plain JavaScript) method that I haven't found?

  18. I've considered and toyed with the second container idea, but the issue there is that the gradient ellipse is  NOT distributed evenly on the "borders" of my vertically shaped div box (and this ALSO makes formatting text more challenging).

    The best alternative (similar effect)  that I can compare to (and may be forced to use) would be a CSS button with a glow effect.

    The difference is that I want that trickling off effect to be contained within a specified boundary (a frame) rather than bleeding into the webpage.

    Ultimately, I would (hypothetically) have 2 rows of 3 divs each showing different products that are available (ie: ice cream pops, cups, cones, sundaes, cakes, weekly special).

    THANKS for helping.

  19. I am trying to achieve a BORDER that will have a gradient effect in itself.

    border: 24px radial-gradient(red 5%, green 15%, blue 60%);

    This isn't working.

    The colors are for testing, but ideally,I would have an effect running from a light blue to a darker blue (similar to the lever that adjust the cool temperature in an air conditioner) and they would outline a div box.

    A button with an edged border could work too

    The key is that I want the gradient to eminate from the center to the outside of the object, not along the border (think of a water droplet in a pond)

     

    PS: the radial gradient in a div with rounded corners just isn't aligning the way it's like it.

     

  20. @kicken  Am I able to do this with .addEventListener ?

    I've tried several alterations of the following with no success.

    var inputs = document.getElementsByTagName('input');
    
    for(var i = 0; i < inputs.length; i++) {
        if(inputs[i].type == 'submit') {
            inputs.addEventListener("click", alert(inputs[i].value);
        }
    }

     

  21. I have TWO buttons inside a form.

    <form onsubmit="return myFunc()">

    myFunc displays a confirmation box after a button is clicked.

    The message would be different depending on which button is clicked, but when I use

    alert(event.srcElement.id);

    I am getting a result that indicates that the FORM has been clicked, not which button has been clicked.

    How can I get the button result in order to create an IF statement for comparisons?

     

     

  22. I'm trying to upload images to a directory, but it seems that no matter how small the file sizes, the largest quantity uploaded is 20.

    I vaguely recall mention of a 20 MB maximum, but for test purposes, most of these files are only a few KB each.

    Any insight on this?

    On a related note, I had written code to reduce file sizes, but since this affects the array of images selected, are they being counted at the original size or the smaller size that results as each file in the array passes through the size-reduction process?

  23. @Nolan81 Your two word response gives no indication as to what EXACTLY you feel is a poor approach with regard to my question.

    Further, you failed to elaborate or provide an alternative solution to any of the previous posts that were informative and appreciated.

    If you read my post, you will see that it concluded by saying

    Quote

    any helpful advice would be appreciated.

    Therefore, you should realize how worthless and idiotic your words were to me and this thread.

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