Jump to content

warewolfe

Members
  • Posts

    57
  • Joined

  • Last visited

    Never

Everything posted by warewolfe

  1. also it may be a good idea to put to following in as well $input = htmlentities($_POST['article_title'],ENT_QUOTES,UTF-; if(checkInput($input)) { echo"accepted<br />"; } else { echo"rejected<br />"; }
  2. function checkInput($string) { return preg_match('/^[a-z0-9\s]*$/i', $string); } This will accept letters, number and spaces. If you want full stops and other punctuation just escape the character and add within the square brackets. eg [a-z09\s\.] will let people add a full stop at the end of a sentence.
  3. What characters to you want to permit? Only Alphanumerics? Or some others like hyphen and single quotes?
  4. Hi, Just in case you come back to check this thread. $some_string = htmlentities($some_string,ENT_QUOTES); would be more secure than a string_replace.
  5. Self deleted. Orginally written in coffee deprived state.
  6. hi, a hint for working in both FF and IE is to have *{ padding:0; margin:0; } at the start of your css file. some of the problem with ie/ff incompatibility is that ie and ff have different default widths for both margins and padding. This code will turn them all off and make you set everything manually. #side-menu img { border-width:0; } should get rid of the border line in both ie and ff
  7. it depends on what the function is suppose to do and how complex a system the function is a part of. If the function is simple and its purpose is to generate atomic html then use echo. ie, if you want to print "hello world" then use echo. If the function is part of more complex system like database systems, Object oriented, and/or implementing the MVC (Model View Controller) architectural pattern then use returns. ie, complexSQLQuery( param1, param2,param3,param 4) { //complext code here return answer }
  8. use isset() to check the variable without the script failing.
  9. have you tried assigning $_POST['Submit'] and echoing to see what is actually being sent?
  10. what do you need help with?
  11. replace for($j=0; $j < count($indiGroup); $j++) { print "<option value=$indiGroup[$j]>$indiGroup[$j]</option>"; } with foreach($indiGroup as $val){ echo"<option = $val> $val </option>";}
  12. You just use the html image tag with an absolute tag. <img src="http://www.whateversite.com/images/some.imagtag" /> This is considered rude when you do it without asking. And they could change the image to whatever they want without you realising it.
  13. Are you confusing Rotate.php with a function call? What does Rotate.php do?
  14. Friendly advice. change the requires to includes and remove the error suppression symbol @ from the start of the lines while you are writing your script so you can see what is going wrong. Also, if you are using apache (I don't know how IIS or other servers do it) then go to the apache logs and check out the last few entries in the error log.
  15. Unless I've misunderstood your question the easiest way is to have a php page that generates a link to each file in your upload directory. Use the directory functions eg scandir() to generate an list of the files you want (filter for the type of files you want to let the user download. Downloading is more an (x)html and browser thing than a php thing.
  16. Congrats, You've told us you need to make a custom popup. You didn't actually post a question or problem though. http://www.plus2net.com/javascript_tutorial/javascript_popup.php Has a tutorial to get you started.
  17. change var myTextareaValue = textareaValue.replace('\n','<br/ >'); to var myTextareaValue = myTextareaValue.replace(/\n/g, /<b r>/ ); The g switch makes the changes global. I'm not certain if you can escape the forward slash in the <b r /> replacement section but if you can it'll probably look like /<br \/>/ I added a space in the br to stop the line from breaking
  18. Just had a D'oh moment. To clarify for any interested, For some reason, I don't understand just yet, if I want to change the something the page displays outside of a table I use; document.getElementById.innerHTML = "some value"; but inside of a table <td> tag I need to use; document.getElementById.value="some value";
  19. Just some general ideas, first I don't know just how long your arrays will be so it may be a good idea to sort both arrays with. It may not matter. array1.sort; array2.sort; then nest some for loops for comparison. function arrayCompare(array1, array2) { var answer=false; for(var ii = 0;ii<array1.length;ii++) { var target=array1[ii]; for(var jj=0;jj<array2.length;jj++) { var comparison=array2[jj]; if(target == comparison) { array1.shift();//remove matching elements from the first array. break;// and get out of the loop. } }//end jj for loop }//end ii for loop // if after removing all the matching elements in the first array // the array length is zero then you've got a match. if(array1.length <1) { answer = true; } return answer; }//end arrayCompare Caveat Please note I haven't actually tried this as I'm about to head to bed. I don't know if you've considered what happens with multiple instances of numbers. This will destroy the first array, if you want to keep it, send the function a copy of the original.
  20. Off the top of my head Make the Submit a class with the style of visibility:hidden and then set it to visibility:visible in the Activate function with a innerHTML call.
  21. Hi, I'm new to javascript and trying to get this thing up and running as a glorified hello world script. The testfunction works as expected but I can't seem to get the innerHTML of the table. Anybody know whats up? <?php /* * This functions just provides a simple id name for * each cell. It could probably have been done easier */ function getCellID($ii,$jj) { $answer= 'c'.$ii.$jj; return $answer; } /* * This function gives the table a cross hatch look */ function sortTDType($ii,$jj) { $answer="tdp"; if($jj>=3 && $jj<=5) { $answer="tdh"; } else if($ii >= 3 && $ii <=5) { $answer="tdh"; } if(($ii >= 3 && $ii<=5)&& ($jj >= 3 && $jj <= 5)) { $answer="tdp"; } return $answer; } ?> <html> <head> <title>Sodoku Solver Prototype seven</title> <link rel="stylesheet" type="text/css" href="prototype7.css" /> <script language = "JavaScript" type="text/javascript"> <!-- function validCheck(var1,var2) { var answer=true; var vector='c'+var1+var2; var vectorValue =document.getElementById(vector).value; //column check for(var ii=0;ii<=8;ii++) { var checkCount=ii+1; var testVector='c'+ii+var2; var testVectorValue = document.getElementById(testVector).value; /* alert('check ' + checkCount + ' : vector '+ vector+ '= ' + vectorValue + ' : testVector ' +testVector +'= ' + testVectorValue); */ if(vectorValue==testVectorValue && vector != testVector && vectorValue!=0) { alert('You Can not put that there, clash on column!'); answer=false; break; } }//end for loop //row check for(var ii=0;ii<=8;ii++) { var checkCount=ii+1; var testVector='c'+var1+ii; var testVectorValue = document.getElementById(testVector).value; /* alert('check ' + checkCount + ' : vector '+ vector+ '= ' + vectorValue + ' : testVector ' +testVector +'= ' + testVectorValue); */ if(vectorValue==testVectorValue && vector != testVector && vectorValue!=0) { alert('You can not put that there, clash on the row'); answer=false; break; } }//end for loop return answer; }//end function validCheck function resetField(var1,var2) { var vid='c'+var1+var2; document.getElementById(vid).innerHTML ='0'; } function validEntry(var1,var2) { var vector='c'+var1+var2; var orginal= document.getElementById(vector).value; if(!validCheck(var1,var2)) { alert('Not working, try again'); resetField(var1,var2); } } //--> </script> </head> <body> <h1>Prototype 7:Intial Form Side</h1> <h2>Input the initial sodoku form</h2> <form action="Prototype7Script.php" method="post"> <table class="displayTable"> <?php for($ii=0;$ii<=8;$ii++) { echo"<tr>"; for($jj=0;$jj<=8;$jj++) { $cellID=getCellID($ii,$jj); $tdtype=sortTDType($ii,$jj); echo"<td> <input class=\"$tdtype\" type=\"text\" value=\"0\" size=\"1\" maxlength=\"1\" id=\"$cellID\" name=\"data[$ii][]\" onblur=\"validEntry($ii,$jj)\" /> </td>"; } echo"</tr>"; } ?> </table> <input type="submit" value="submit"> </form> <script type="text/javascript"> function testText() { document.getElementById('testID').innerHTML = 'zzzz'; } </script> <p>Another <b id='testID'>test</b></p> <input type='button' onclick='testText()' value='tester button' /> </body> </html>
  22. Hi, I know this is phpfreaks but javascript would probably be your best bet with this sort of problem and using alert boxes to warn/inform the user. Add this script in the head section of your page. <script language="javascript" type="text/javascript"> function warning() { if(criticalInformationCheck()) { alert("Warning! Warning! Warning!, you might want to change warning to something useful"); } function criticalInformationCheck() { var answer = true; //how this will work will depend on the DOM of the page you are generating. //eg if div exist then anwer is false // or if div is empty then answer is false return answer; } } </script> and add this to the body tag <body onload="warning()">
×
×
  • 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.