Jump to content

bluebutterflyofyourmind

Members
  • Posts

    113
  • Joined

  • Last visited

    Never

Everything posted by bluebutterflyofyourmind

  1. tonight i'm gonna do some work with some AJAX and start from fresh and see if i still get the problem where i'm stuck at readystate 1 without those alerts. will let you know if i figure out how to fix it. kinda glad to know it happened to you too though as i was worrying it was the server i was on....thus meaning now i know i should be able to fix it somehow. ttyl
  2. if you look in this thread... i posted a long thing in the middle pretty much telling you how to do what you're wanting to do. look through that and give it a try. let me know if you have any questions http://www.phpfreaks.com/forums/index.php?topic=208701.new;topicseen#new
  3. not sure if i'm missing something here but how does that address my problem?
  4. Hey there. so this is all AJAX. have you dealt with AJAX before?
  5. so did you get the javascript working where it checks the length of what's being typed in and whether or not its a number....and then displays whether or not the input meets those two requirements?
  6. the first thing you want ot get working is just the javascript side of things. don't worry about the ajax and php at first. create a function that is called everytime a key is pressed (onkeyup = "check();") in your javascript check the length of what is being entered and also check to see if it's a number. the way i do that is divide it by 1 and see if it's equal to the original input. if it's a number this should be true. i'd say get that working first. make it so that when you type the right length of numbers into the text box, another text box is updated to just say that you reached the right amount of numbers. hint: also use maxlength in the input to limit the max number of characters that can be entered. let me know when you get that workin.
  7. Hey there. I know other's have posted with problems getting past ready state 1 but none that address my problem. For some reason in my code, if I put alerts before and after my .send(null) everything works great. Without these alerts(ie:like normal) I get stuck at ready state 1. I have no idea what im' doing wrong or why alerts would have this kind of affect. I'm desperate to fix this problem. any help is greatly appreciated! thanks! -grant not working function submitShout(){ httpObject = getHTTPObject(); name = getElement("nameID"); city = getElement("cityID"); shout = getElement("shoutID"); submitted = getElement("submitID"); namesubmit = encodeURIComponent(name.value); citysubmit = encodeURIComponent(city.value); shoutsubmit = encodeURIComponent(shout.value); if (httpObject != null) { httpObject.open("GET", "shoutupdate.php?submit="+submitted.value+"&shouter="+namesubmit+"&city="+citysubmit+"&shout="+shoutsubmit, true); httpObject.send(null); httpObject.onreadystatechange = setOutput("outputID"); } document.form.reset(); submitted.disabled = true; } Working wiht Alerts included function submitShout(){ httpObject = getHTTPObject(); name = getElement("nameID"); city = getElement("cityID"); shout = getElement("shoutID"); submitted = getElement("submitID"); namesubmit = encodeURIComponent(name.value); citysubmit = encodeURIComponent(city.value); shoutsubmit = encodeURIComponent(shout.value); if (httpObject != null) { httpObject.open("GET", "shoutupdate.php?submit="+submitted.value+"&shouter="+namesubmit+"&city="+citysubmit+"&shout="+shoutsubmit, true); alert("just press ok"); httpObject.send(null); alert("we'll fix this issue soon"); httpObject.onreadystatechange = setOutput("outputID"); } document.form.reset(); submitted.disabled = true; }
  8. gah i've no help yet on that problem. trying to contact a guy on this forum right now that might possibly know. I haven't found much help yet online. I also don't understand why having the alerts makes it work. they should have no effect on the code....right? in your first body of code that you posted there, when you're sending your variables to you php file, you're not sending the encrypted ones. right now you're sending select1.value....when you should be sending select1submit. glad to see that you got it working....minus my stupid bug. i'm still looking for help on that....so let me know if you figure anything out or find anything. i'm not too sure what the code's doing wih .send(null). possibly that's what's needed to send off the request. really have no idea :S
  9. are all the id's the same length? or do you want it to look for a name after every key press? what is this being used for? as if you have it check after every key press, people can "fish" for name/id associations by just typing in numbers to see who belongs to what id. that could be a security risk. answer these questions and i should be able to better help you. later. -grant
  10. alllrighty. first things first. before, your form's mthod would be post or get and action would target your php file. here you now make your form target a javascript function which submit's the form to the php file. and you remove the method property all together. In your javascript file, have a function that collects and submits to the php file. This is all AJAX, so it will be done in the background. if you want the form submission to not AJAX then just target your php file and mthod like normal and process with PHP. This is my understanding of what you're doing. having select boxs that change depending on the other's inputs. if these values never really chnage then you can use javascript only. or if you need to query a databse, then you must use ajax which will be similar to the example i'm about to show, jsut you'll be echoing the innerHTML of the select box (ie: echo"<option>thing</option>" so what i'm showing you here is a form that has multiple values submitted, and then passed to a php file, whose echo'd text is then displayed in teh page (mines inside a placeholder div. could be anything.) sooo here goes. function that submits values from form function submitShout(){ httpObject = getHTTPObject(); name = getElement("nameID"); city = getElement("cityID"); shout = getElement("shoutID"); submitted = getElement("submitID"); namesubmit = encodeURIComponent(name.value); citysubmit = encodeURIComponent(city.value); shoutsubmit = encodeURIComponent(shout.value); if (httpObject != null) { httpObject.open("GET", "shoutupdate.php?submit="+submitted.value+"&shouter="+namesubmit+"&city="+citysubmit+"&shout="+shoutsubmit, true); alert("just press ok"); httpObject.send(null); alert("we'll fix this issue soon"); httpObject.onreadystatechange = setOutput("outputID"); } document.form.reset(); } as you see there are alert's there that appear to do nothing...but for some reason with out them the code get stuck at a readystate 1(google ajax onreadystatechange) and i'm working with people to sort this problem out on this forum as well. from that code you need to get the xmlHTTPrequest(which is what allows the php call to be made in the background) function getHTTPObject(){ var xhr; try { xhr = new ActiveXObject('Msxml2.XMLHTTP'); return xhr; } catch (e) { try { xhr = new ActiveXObject('Microsoft.XMLHTTP'); return xhr; } catch (e2) { try { xhr = new XMLHttpRequest(); return xhr; } catch (e3) { xhr = false; return xhr; } } } } I also have a function gets the element from the specific id given. so every input of your form has to have an id associated with it function getElement(id){ if (document.getElementById){ // this is the way the standards work var el = document.getElementById(id); }else if (document.all){ // this is the way old msie versions work var el = document.all[id]; }else if (document.layers){ // this is the way nn4 works var el = document.layers[id]; } return el; } After assigning the gotten elements to variables, you must encode these(if they are text) as if they have &'s in teh text, the AJAX will not work properly. (i found this out the hard way lol). then come the AJAX. so referencing that first code block i sent in this post, if (httpObject != null) { httpObject.open("GET", "shoutupdate.php?submit="+submitted.value+"&shouter="+namesubmit+"&city="+citysubmit+"&shout="+shoutsubmit, true); alert("just press ok"); httpObject.send(null); alert("we'll fix this issue soon"); httpObject.onreadystatechange = setOutput("outputID"); } this is the AJAX part. the open function is where info is sent to your php file. you must set it to GET as you are passing though the url(it will never be seen) then you have the url itself and then TRUE, which makes it send asynchronously(in the background). the url is just your usual url but with your variables mixed in. pay attention to where you have encoded and unencoded variables. the unencoded ones need to be variable.value where as the encoded ones already have taken into account the .value property. you could clean this up before the url stage but i was just lazy to fix it after. then you .send(null) (not 100% what's going on here, as this is where my code doesn't work properly without the alerts.) and then the part where your javascript listens for a response from the php file httpObject.onreadystatechange = setOutput("outputID"); "outputID" is just a placeholder div i had. that would be the id of your select box if that's what you're doing. the setoutput code is thus function setOutput(id){ var output = getElement(id); if(httpObject.readyState == 4){ output.innerHTML = httpObject.responseText; } else if(httpObject.readyState == 0){ output.innerHTML = "ready state = 0"; } else if(httpObject.readyState == 1){ output.innerHTML = "ready state = 1"; } else if(httpObject.readyState == 2){ output.innerHTML = "ready state = 2"; } else if(httpObject.readyState == 3){ output.innerHTML = "ready state = 3"; } else{ output.innerHTML = "<img src=\"images/waiting.gif\"/>"; } } State Description 0 The request is not initialized 1 The request has been set up 2 The request has been sent 3 The request is in process 4 The request is complete these are what the numbers mean. mine gets stuck at one without the alerts. so upon reaching 4, you update the innerHTML of whatever thing you're updating with the .responseText This is what ever the php file echo's so in my php file, if they messed up on something, echo what they did wrong and that would display in teh placeholder div. or echo your <option>'s for your select box. I know this is a lot to take in but i managed to learn it in about a week due to a deadline...my knowledge isn't too comprehensive but i've done what your asking so figured i'd contribute the code. don't hesitate to ask questions about anything i posted as i know it can be kinda confusing. Later! grant
  11. what you do is give each select box an id. then in your javascript, you can refer to the element(the select box) via that ID. in that select box, make onchange, onfocus, and onblur go to a javascript function that changes the other select boxes depending on what value was selected in the first. Have the other select boxes created already with nothing, or anything you want in them. then when that first one is changed, update the the other boxes. if you're dong simple stuff that'll be the same everytime, then this can all be done in javascript with no AJAX. otherwise, use AJAx calls. In your php file, build what you want inside your select boxes using echo's. then back in you javascript file, make the innerHTML of your select box equal to the response text of the php file, which will be the echod text from the php file. hope this helps! -grant
  12. Hi there i'm having a very strange problem when trying to use xmlhttprequest. I create my new xmlhttprequest and all is fine and i send my values from a form to a php file where the back end work is done. here's the code that takes from the form. //run when shout form is submitted function submitShout(){ httpObject = getHTTPObject(); name = getElement("nameID"); city = getElement("cityID"); shout = getElement("shoutID"); submitted = getElement("submitID"); namesubmit = encodeURIComponent(name.value); citysubmit = encodeURIComponent(city.value); shoutsubmit = encodeURIComponent(shout.value); if (httpObject != null) { httpObject.open("GET", "shoutupdate.php?submit="+submitted.value+"&shouter="+namesubmit+"&city="+citysubmit+"&shout="+shoutsubmit, true); alert("just press ok"); httpObject.send(null); alert("we'll fix this issue soon"); httpObject.onreadystatechange = setOutput("outputID"); } document.form.reset(); } code to get xmlhttprequest // Get the HTTP Object function getHTTPObject(){ var xhr; try { xhr = new ActiveXObject('Msxml2.XMLHTTP'); return xhr; } catch (e) { try { xhr = new ActiveXObject('Microsoft.XMLHTTP'); return xhr; } catch (e2) { try { xhr = new XMLHttpRequest(); return xhr; } catch (e3) { xhr = false; return xhr; } } } } the code to set my output back to the user //set output span of given page function setOutput(id){ var output = getElement(id); if(httpObject.readyState == 4){ output.innerHTML = httpObject.responseText; } else if(httpObject.readyState == 0){ output.innerHTML = "ready state = 0"; } else if(httpObject.readyState == 1){ output.innerHTML = "ready state = 1"; } else if(httpObject.readyState == 2){ output.innerHTML = "ready state = 2"; } else if(httpObject.readyState == 3){ output.innerHTML = "ready state = 3"; } else{ output.innerHTML = "<img src=\"images/waiting.gif\"/>"; } } and here's a bit of code that just lets me get the element by ID function getElement(id){ if (document.getElementById){ // this is the way the standards work var el = document.getElementById(id); }else if (document.all){ // this is the way old msie versions work var el = document.all[id]; }else if (document.layers){ // this is the way nn4 works var el = document.layers[id]; } return el; } My problems lies with in submitShout(). Currently there are two alerts in there just to make the user press ok. with these alerts in the code i successfully reach a readystate of 4. When i remove those alerts, i get stuck at a readystate of 1, which means the send was not called. the whole process works no matter what though, the values go to the php file and they go to the database, just for some reason, without these alerts, it doesn't work. This happens on all my AJAX functions which are of similar nature. This is a very annoying problem and i don't understand why Alerts affect the code like that. any help to resolve this problem is greatly greatly apreciated! thanks for taking the time to read this. -grant
  13. Haven't had chance to try it yet but that looks like exactly what i'm looking for. after passing that to my php script though, how do i work with what's passed? Do i need to decode? and if so how? thanks a ton!
  14. Hey there so i'm trying to pass a body of text through ajax to my php script. the issue is that if they put in an & or sometimes quotes, the text gets messed up. the quotes are just an html thing i guess. but the & cause the AJAX line passing the variable to the php to think that everything after is now a new variable. is there a way to pass text, and have it isolated so that it doesn't affect the javascript? thanks!
  15. Hey there. so I have a javascript file that submits to a php file to do the work. I'm running into a problem where my readyState is stuck at 1 which means the httpObject.send(null); did not work. when i put alerts before and after it though it works properly! I don't understand why and really need to fix this. //run when shout form is submitted function submitShout(){ httpObject = getHTTPObject(); name = getElement("nameID"); city = getElement("cityID"); shout = getElement("shoutID"); submitted = getElement("submitID"); if (httpObject != null) { httpObject.open("GET", "shoutupdate.php?submit="+submitted.value+"&shouter="+name.value+"&city="+city.value+"&shout="+shout.value, true); alert("before"); httpObject.send(null); alert("after"); httpObject.onreadystatechange = setOutput("outputID"); } document.form.reset(); } //set output span of given page function setOutput(id){ var output = getElement(id); if(httpObject.readyState == 4){ output.innerHTML = httpObject.responseText; } else if(httpObject.readyState == 0){ output.innerHTML = "ready state = 0"; } else if(httpObject.readyState == 1){ output.innerHTML = "ready state = 1"; } else if(httpObject.readyState == 2){ output.innerHTML = "ready state = 2"; } else if(httpObject.readyState == 3){ output.innerHTML = "ready state = 3"; } else{ output.innerHTML = "<img src=\"images/waiting.gif\"/>"; } } anybody have any ideas? thanks!
  16. Yeah i will deffinately have to learn sharepoint as they've spent alot of money on it. Right now i'm drowning in tryig to figure out what to do so i will deffinately take a look at teh support doc you posted. I currently just wanted to quickly make a calender service to fix a current site. I know how to do it in PHP but I will deffinately have to do more research on sharepoint. right now i just feel like i'm in a bit over my head. Either option results in a lengthly process, either installing PHP on the server, or learning sharepoint. as i'm gong to have to eventually i'll take a look at the second option. thanks for the help!
  17. ohhh man just found out php isn't installed on this server....now i have to figure out how to. thanks for the help in the mean time.
  18. when i upload a php file to this current server, it says the file does not exist though it does. I'm also accessing the site via an ip address that's here on the local server (ie: not visible to the world) does that make a difference with regards to php?
  19. you can do a simple resize using html in the image tags <img src="" height=xx width=xx /> This is useful for making thumbnails though dependnig on the size of the image, they may take a while to load. also the width and height you would need to calculate to keep them proportional. If you want to resize an image say for upload, before y ou save it to the server you have to go through a more complex process. does the simpler method above suffice? or to you need to resize the image being saved to a server? what is your situation?
  20. oh and the server is running SQL Server 2005. not sure if that means i have to do anything different
  21. what program do you use for your development/progarmming? They really want me to work with Microsoft Sharepoint. you have any experience with that?
  22. Hey there everybody. I've always developed PHP on servers running LAMP and used phpMyAdmin and what not. I'm now working for a company that is running a microsoft server running "Microsoft-IIS/5.0" What do I have to do differently to write php on a microsoft server than a linux server? Where is there a good online resource like the help i've found here for this type of programming? I think i've asked/explained in the most straight forward way but just ask if you're confused. Thanks!
  23. It looks pretty solid to me. You probably won't find all that much on security around as it is very specific to each application. Every time you create an upload page for something the circumstances are gonna be different. All you gotta do is run a ton of checks like you have to look for every possible scenario. I really suggested trying to "break" your code by trying to upload in ways it should reject you. This is normally the most lengthly process as the number of combinations are sometimes endless....but it never hurts to try to break your code. If you find a hole and write some more script to patch it up. Eventually you should feel confident that it's secure. hope this helps
×
×
  • 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.