Jump to content

premiso

Members
  • Posts

    6,951
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by premiso

  1. glob <?php $path = "/home/folder01/*"; $files = glob($path); sort($files); $badNames = array(".", "..", "index.php", "error_log", ".htaccess", "getfile.php"); foreach ($files as $filename) { if (!in_array($filename, $badNames)) { echo '<a href="' . $filename . '">' . $filename . '</a><br />'; } } ?> Should do it for you.
  2. $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "driving_directions")) { $insertSQL = sprintf("INSERT INTO driving_directions (from_addr) VALUES (%s)", GetSQLValueString($_POST['from_addr'], "text")); mysql_select_db($database_ldregister, $ldregister); $Result1 = mysql_query($insertSQL, $ldregister) or die(mysql_error()); $insertGoTo = "data.php?data=$fromaddress"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } } mysql_select_db($database_ldregister, $ldregister); $query_rs_directions = "SELECT * FROM driving_directions WHERE from_addr = '$editFormAction'"; $rs_directions = mysql_query($query_rs_directions, $ldregister) or die(mysql_error()); $row_rs_directions = mysql_fetch_assoc($rs_directions); $totalRows_rs_directions = mysql_num_rows($rs_directions); $fromaddress = str_replace(" ","+",$row_rs_directions['from_addr']); header(sprintf("Location: %s", $insertGoTo)); ?> Move the header after those statements?
  3. Class b needs to extend class a. Also you should really put the class definitions in a separate file and include it.
  4. I do not see where you attempted to do that code. $dirname = substr($dirname, 2); Should remove the first 2 items from the name. EDIT: Beaten to it, but a correction was needed. Should be 2 not 1.
  5. $sql = mysql_query("SELECT userId1, userId2 FROM life_approval WHERE (`userId1` = '{$_SESSION['valid_user']}' OR `userId2` = '{$_SESSION['valid_user']}') AND `approve` = 'Approved'"); This is really a MySQL question and should be posted in that forum. But the above should get you what you want in 1 statement.
  6. money_format
  7. <?php echo nl2br($this->escape( $forum->comment));?>
  8. <?php include("config_members.php"); // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); $row = mysql_fetch_assoc($result); $userav = $row['Profile_picture']; // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file // session_register is depreciated and is not needed. //session_register("myusername"); //session_register("mypassword"); $_SESSION['myusername'] = $myusername; $_SESSION['myavatar'] = $userav; if (strcmp($myusername, "admin") == 0) { header("location:admin_profile.php?username=$myusername"); }else { header("location:my_profile.php?username=$myusername"); } exit(); } else { echo "<h1 class=login_status>Wrong Username or Password</h1>"; } ?>
  9. What does the escape function do? If it uses htmlentities or strip_tags then that is your problem. But if this is for inserting it into the DB I would not do nl2br before putting the data into the DB. Instead do it when retrieving the data. You want to store the data in it's raw format.
  10. Why not just have each entry in the text file comma separated, then you open that file with file and sort the array how you want? It seems you are going about this the long way. Instead of the switch, you can use in_array
  11. Yea, I guess I overlooked that when looking through the array functions Thanks.
  12. $userPoints[$users[$i]] = $points[$i]; Modify that part as it should be $points not $point. That was my mistake.
  13. The best thing is, I have dedicated hosting, so full access to the php.ini. I will make sure that is set to be off.
  14. As a follow-up question, what about us folks who start sessions automatically in the ini file ? For my Oracle Object, I get "Incomplete_Object" because of it... It doesn't seem to be causing my application any harm... Is it "safe" to continue using an incomplete object ? What are the ramifications ? Thanks, Scot L. Diddle, Richmond VA I would use the autoloader as pointed out. As far as the incomplete object, I do not think it is kosher. If that does not answer your question, open up a new topic please. Topic Solved.
  15. That must be the kicker that I never got to work. Thanks for that PFMaBiSmAd. Yea, I have seen the autoload, I have not looked into it. But I will and see if that works. Thanks.
  16. Hey, Just curious on storing Objects in Session with PHP. I know .NET does this regularly and was wondering if anyone had any reason why this would be avoided. Basically I am going to have a Person Class that extends Address. A person can have 1 or more addresses. I want to store this person class in an object in session when they are modifying their data (UserCP). So instead of having to re-query each time, I just store that in session and make an isDirty variable so when they are done, it checks that variable. If anything has been changed it updates the database. I do not really see anything wrong with this, but given that PHP's OOP is still getting the tweaks worked out I figured I would see if anyone had any thoughts. Thanks!
  17. setcookie('ID_my_site', false); setcookie('Key_my_site', false); Give that a try. setcookie EDIT: If that fails, follow PFMaBismAd instructions. Also you should set the past to be at least 1 year ago, due to timezone differences.
  18. Back to my original theory. $user=$_POST['userimgnm']; That line is not populating $user correctly. Try printing it out and see if that is what you expect. If it is not there is your issue.
  19. $users = '1;7;5;3;6;2'; $users = explode(";", $users); $points = '10;12;8;11;8;9'; $points = explode(";", $points); $cnt = (count($users)-1); for ($i=0;$i<$cnt;$i++) { $userPoints[$users[$i]] = $point[$i]; } rsort($userPoints); print_r($userPoints); sort look at the different sort commands.
  20. $users = '1;7;5;3;6;2'; $users = explode(";", $users); $points = '10;12;8;11;8;9'; $points = explode(";", $points); $cnt = (count($users)-1); for ($i=0;$i<$cnt;$i++) { $userPoints[$users[$i]] = $point[$i]; } print_r($userPoints); Give that a try. There might be a better way, but that should work.
  21. It is possible, even with how Stephen did it. However, a major downside to that is anyone can access any table. I would setup an array with valid table names (only tables you want this script to have access to), if the get value is in the array then use it. If not throw an error to prevent anything bad happening. Just a question, why would you want to do it this way?
  22. Well the session would not exactly work, as it would overwrite the previous data. At least in the sense I showed you. What I would do, given that only 1 name per page load is allowed is still use sessions, but do this instead. <?php session_start(); if (isset($_POST['name'])) { $_SESSION['names'][] = $_POST['name']; } ?> <form action="seats.php" method="post"> Enter Names: <input type="text" name="name" /><br/> Finished signing in? <input type="checkbox" name="ready" /><br/> <input type="submit" name="submit" /> Then to display them: <?php session_start(); $names = isset($_SESSION['names'])?$_SESSION['names']:array(); echo "<pre>" . print_r($names, 1) . "</pre>"; ?> Sorry for the first post, sometimes it makes sense in your head till you re-read it.
  23. To Check EMail you need IMAP support and php functions, if you want to code it yourself. For your own email you can check it with whatever you want, whether it is GMail, OutLook The Bat, Thunderbird etc. If you want it done PHP, you should look for an email script or use imap to code it yourself. As for sending mail on localhost, you cannot without a mail server. Which I doubt you have installed, given you are on Windows. An easy solution around this is to signup for a GMail account and use phpGMailer (google that) to send out emails over GMail's server SMTP. Or signup for a "Free" (if there are any) SMTP server and add those items to the php.ini. But for that you need to make sure your ISP does not block Port 25.
  24. $score = $score . "\n"; if ($arrayCount < 10) { //Add new name and score to end $scoresArray[$finalName] = $score; } elseif ($score > end($scoresArray)) { array_pop($scoresArray); $scoresArray[$finalName] = $score; } Should solve the issue.
  25. <form action="seats.php" method="post"> <?php foreach ($_POST as $key => $value){ echo $value; echo "<input type=\"hidden\" name=\"pnames[$key]\" value=\"$value\">"; } ?> Enter Names: <input type="text" name="name" /><br/> Finished signing in? <input type="checkbox" name="ready" /><br/> <input type="submit" name="submit" /> See if that works how you want it. On a side note, is there a reason you are not using sessions to do this? <?php session_start(); $_SESSION['POST'] = $_POST; ?> <form action="seats.php" method="post"> Enter Names: <input type="text" name="name" /><br/> Finished signing in? <input type="checkbox" name="ready" /><br/> <input type="submit" name="submit" /> seats.php <?php session_start(); $postData = isset($_SESSION['POST'])?$_SESSION['POST']:array(); $_POST = array_merge($_POST, $postData); echo "<pre>" . print_r($_POST, 1) . "</pre>"; ?> Should give you a rough overview of how that would work.
×
×
  • 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.