Jump to content

goocharlton

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

goocharlton's Achievements

Member

Member (2/5)

0

Reputation

  1. I am referring to the following script. <?php $specialties = array("Variable 1", "Variable 2"); $i = 0; extract($_POST['specialties']); foreach($specialties as $value) { if (isset($_POST['specialties'])) { $checked = ''; if ($specialties[$i] == $value) { $checked = ' checked'; } } echo "<tr><td><input name='specialties[]' type='checkbox' value='$value'$checked /></td><td>$value $i</td></tr>"; ++$i; } ?> I am creating a list of checkboxes for my form using an array. I have setup the script to check if all fields are filled in before it submits itself. If the validation doesn't pass then the script reloads the form with the field filled with the details the user had entered. I am trying to also make it so the checkboxes that the user had selected before validation are still checked after they don't pass validation. I have tried doing so using: <?php if ($specialties[$i] == $value) { $checked = ' checked'; } ?> ...but I am unable to get $specialties[$i] to work correctly. I have tried $specialties[0] and the script works fine for the first checkbox which is of course what I want for the all the checkboxes. That is why I have tried using $i but not successfully. Is there a better way of doing this? What am I doing wrong?
  2. Thanks but you don't understand what I am asking. I am defining 'reloadElement' to the HTML tag id that I want it to replace, not the tag id in which it is in. Using filter('{item}',this.id,this.value) is defining reloadElement to the HTML tag in which it is in, where as using filter('{item}','{reloadElement}',this.value) I am able to define {reloadElement} every time I insert the function. Do you understand?
  3. Sorry mate, i'm fairly new to this. Could you please expand on what you said.
  4. I have a function in my PHP script that I use to filter content by HTML tag id when the item changes in the drop down menu as seen below: <?php echo '...'; echo '<div id="filter"><form style="padding:0;margin:0;">Filter: <select name="collection" onchange="filter(\'albums\',\'reload\',this.value)">'; echo '...'; ?> The javascript variable that I am using for the onchange event is: filter('{item}','{reloadElement}',this.value) where: {item} = a variable that is used to define what part of the filter.php script to run {reloadElement} = defines what HTML tag by id to reload(using ajax) this.value = just grabs the id that the drop down menu item is holding For example: filter('album','content',this.value) The following runs the 'album' part of the filter.php script and used 'this.value' to to grab content from the database then it reloads the HTML tag with id 'content' using AJAX. The AJAX script that I am using is: var xmlHttp function filter(type,reloadElement,value) { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } var url="filter.php" url=url+"?type="+type url=url+"&value="+value url=url+"&sid="+Math.random() xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url,true) xmlHttp.send(null) } function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById(reloadElement).innerHTML=xmlHttp.responseText } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { //Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } Which then calls filter.php to grab the new content to be reloaded. My problem is with getting the {reloadElement} to be the tag id that is reloaded by the AJAX script. Somehow I need to get: .getElementById(reloadElement). as seen in the stateChanged function to be defined by the middle variable in the filter funtion. How do I achieve this?
  5. I have a website that I am trying to get URL rewriting working on it. This scenario is as follows: The URL in the browser shows .../page/1 and is interpreted by mod_rewrite as .../handler.php?page=1 with the following .htaccess file: Options +FollowSymLinks RewriteEngine on RewriteRule page/([0-9]+)$ /handler.php?$page=$1 I try using the PHP GET function to call the page number. I tried using the following code but it just returned blank: <?php $page = $_GET['page']; echo $page; ?> What am i doing wrong?
  6. From what I could understand this is what you are looking for: <?php $test = file_get_contents('http://game.endless-online.com/playerlist.html'); //echo $test; preg_match_all('|<td width="155"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td><td width="155"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td><td width="50"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td><td width="100"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td><td width="70"><font face="Arial" size="2" color ="#111111">\s+(.*?)</font>\s+</td>|is',$test, $out); echo '<table><tr><td>Name</td><td>Title</td><td>Level</td><td>Experience</td><td>Gender</td></tr>'; foreach ($out[0] as $k => $v){ echo '<tr><td>', $out[1][$k], '</td><td>', $out[2][$k], '</td><td>', $out[3][$k], '</td><td>', $out[4][$k], '</td><td>',$out[5][$k], "</td></tr>"; } echo '</table>'; ?>
  7. Any ideas on how I can build an application that guesses the number that people are thinking of? I figured the way to do it it to get the script to ask questions that the user asks yes or no too till it gets to a small enough possibility to get the exact number. I.e. The script will ask, "Is you number 50 or higher?" -- if yes "Is your number 75 or higher? ---- if yes "Is your number..." ---- if no"Is your number..." -- if no "Is your number 25 or higher? ---- if yes "Is your number..." ---- if no"Is your number..." ...etc I can easily run the script in a way that goes through every single possibility and possible path running if and else but that will take days of going through every single possibility, can you think of a better way of doing it? Possibly using an array to array the possibilities > what are your thoughts?
  8. Thanks guys. GuiltyGear could you please expand on your answer and give an explanation?
  9. I am trying to close a php session from a link that the user clicks. For example, I want the user's session to end when he clicks "(logout)". How do I do this?
  10. Here is the code I am trying to use: <?php session_start(); $result = mysql_query("SELECT username, password FROM user WHERE username='password'"); $passwords = mysql_fetch_assoc($result); if ($_POST['password'] == $passwords[$_POST['username']]) { echo "Login Successfull"; $_SESSION['auth_username'] = $_POST['username']; } else { ?> <form method="post"> <div class="login-form"> Username<?php if(isset($_POST['login']) and !$_POST['username']) { echo "<span style='color:#FF0000;'>*</span>"; } ?><br> <input name="username" type="text"> </div> <div class="login-form"> Password<?php if(isset($_POST['login']) and !$_POST['password']) { echo "<span style='color:#FF0000;'>*</span>"; } ?><br> <input name="password" type="password"> </div> <div class="login-button"> <input name="login" type="submit" value="Login" style="width:40px;"> </div> </form> <?php } ?> What am I doing wrong?
  11. ....go on. What were you saying about ajax/iframe code, can you explain more about this? Just viagra adds and crap like that. I'm not fussed with the fact that the hacker got in, I know how he got in and when he got in(nothing special I know) but I just want to try and track him down that's all.
  12. He is running a php extension. You don't understand, I can easily stop him from running the script, the fact is that I don't want to stop him at this stage, I want to catch him!
  13. Ok here goes! I have been hacked numerous times by the same hacker spamming my site. He uploads a file to a directory and then accesses the file through his browser which them edits files on my domain that he specifies. I have just fixed all the pages that were spammed on my site for the 3rd time and it will not happen again because I actually took the effort to close the hole in which he was entering by. He(whether in person or from a scheduled program) returns daily to run the script that he had uploaded to re-spam my pages. He is no noob because he runs it all from behind proxy's so I am unable to track him that I am aware of. Because he runs this script everyday I am wondering if I can use that against him in some way. As he is behind a proxy this will be much harder or impossible but where there is a will there is a way! I need to know if there is any way to get details of a user through a proxy with php or is there some way I can trick him through it? I can edit the file that he runs off my server every day to whatever I want. What do you think?
  14. I have a content area with width that varies according to whether there are left or right modules(this is a joomla cms site). I have written this code but I cant get it to work.... <div id="content" style="width:<?php if ((mosCountModules( "left" )) < 0): if ((mosCountModules( "right" )) < 0) echo "800";; elseif ((mosCountModules( "left" )) > 0): if ((mosCountModules( "right" )) > 0) echo "380";; elseif ((mosCountModules( "left" )) < 0): if ((mosCountModules( "right" )) > 0) echo "590";; elseif ((mosCountModules( "left" )) > 0): if ((mosCountModules( "right" )) < 0) echo "590";; endif; ?>px"> </div> Can anyone tell me what I am doing wrong, if you dont know anything about Joomla do you know whats wrong with the php i have writen?. I am trying to say that: - If there are no modules in the left AND right columns echo a width of 800px. - If there are modules in the left AND right columns echo a width of 380px. - If there are modules in the right AND not in the left columns echo a width of 590px. - If there are modules in the left AND not in the right columns echo a width of 590px.
×
×
  • 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.