Jump to content

hoopplaya4

Members
  • Posts

    161
  • Joined

  • Last visited

    Never

Everything posted by hoopplaya4

  1. Hello all, I'm struggling writing some code (or figuring out where to start). I'm trying to write some code that will allow me to find the number of Saturdays between two dates. For example, if I have "2/19/2009" and "2/26/09", I would know that there's one Saturday that lands between those dates. Any idea on how to get started? Thanks!
  2. Thanks for the reply. So, now, when attempting to serialize, for some reason, the exec() does not even take place. This is my new code: <?php $arrayhere = array("1","2","3"); $newarray = serialize($arrayhere); exec("php testarray.php $newarray > /home/coachser/public_html/logs/newtest.php &"); It's not even creating the "newtest.php" file. But, I found that when I remove the $newarray from the exec("php testarray.php... portion, then it creates the "newtest.php" file. Any idea what I'm doing wrong here?
  3. Hi All, I'm trying to pass an array using exec(), but I am not able to display the array. Here's what I am using: <?php $arrayhere = array("1","2","3"); exec("php testarray.php $arrayhere > /home/public_html/logs/test.php &"); Then the "testarray.php" page has this: <?php $id = $argv[1]; foreach ($id as $value) { echo $value; } And, when I look at the results, the following error is printed: Any ideas why it wouldn't be displaying the array?
  4. Ok, thanks. So, let's say I pass an array of three usrIDs (32, 35, and 36). (On the next page, it'd obviously be $_POST["name"]). So, on the next page, what would my MySQL SELECT query look like to grab all email addresses from the array?
  5. Hmm...anyone? (Sorry if I'm being impatient!)
  6. Thanks for the replies guys. I'm sorry I was not specific enough: @farewei: I know I need to user $row['usrEmail '], my question is where would I put it? @Maq: First, I know I don't have the action (sorry for leaving it out, wanted to cut down the form). The answer to your second question is "Yes." Every user that is selected from the "multiple select box" has a usrID and a usrEmail. Right now, the form ONLY passes the usrID of the persons selected. However, I also want to pass the usrEmail of that selected person (option) as well. So, I'd like to know how I can go about passing both the usrID (which is already being passed) AND usrEmail. Should I separate it with a comma? <?php print("<option value='" . $row["usrID"] . "," . $row["usrEmail"] . "'>"); And then split it up later? Or is there just an easier way to pass the data as two separate fields? Please let me know if I need to be more specific.
  7. Hi all, I've got a PHP form that has a "Multiple Select" box. Now, here's the thing, I want to pass multiple values through the form based on which options are selected. For example, here's my current code: <form> <select multiple style="width:300px; height:120px;" name="name[]" id="name"> <?php $sql = "SELECT usrID, usrFirst, usrLast, usrEmail"; $sql .= " FROM tblUsers"; $sql .= " WHERE usrActive = '1'"; $sql .= " ORDER BY usrFirst"; require("connection.php"); $rs=mysql_db_query($DBname,$sql,$link); while ($row=mysql_fetch_array($rs)){ print("<option value='" . $row["usrID"] . "'>"); print("" . $row["usrFirst"] . " " . $row["usrLast"] . "</option>\n"); } ?> </select> </form> As you can see, the "value" that's being passed is usrID. However, I'd also like to pass the field usrEmail (from my DB) as well. What is the best way to achieve this? Obviously, I don't want to make a separate "multiple select" box. Would I have to create a "hidden field" or something? Maybe this is something easy, and I'm overthinking. Thanks in advance!
  8. Thanks for the reply. I sort of understand the "$row[0],$row[1], etc..." but, the name of my column is usrEmail, so would the correct syntax be: $row['usrEmail'][0], or what? Also, the number of results in the table is always changing. For example, I may have 30 emails one day, but 35 the next. So how would I go about it so I don't have to count up using [0],[1],[2], etc? Thanks.
  9. Hey All, I've got a question, that's probably easy, but for some reason, I can't figure it out. I have a row in my database that stores user emails. I would like to pull the entire array of emails from the database, and place it into a hyperlink. For example: <a href="mailto:johndoe@example.com, janedoe@example.com, jimdoe@example.com">Email Entire Database</a> However, I'm just not quite sure how to do so. So far, I have: <?php $sql = "SELECT usrID, usrEmail, usrFirst, usrLast"; $sql .= " FROM tblUsers"; require("../connection.php"); $rs=mysql_db_query($DBname,$sql,$link); if ($rs) { $row=mysql_fetch_array($rs) ?> <a href='mailto:<?php echo $row["usrEmail"]; ?>'> But this only displaying the first email. How might I print all emails, separated by a comma? I'm sure this is easy, but I'm not sure how to do it! Thanks!
  10. Thanks for the reply. That's a good start, and something I'll definitely keep in mind. Any other ideas that might be worth implementing?
  11. Hi All, I'm using cookies to "remember" users (after they've closed the browser) and log them back in. However, I'd like to add/set a cookie to where, when users close the browser, but them open it again, it will bring them back to last page they visited on my website. Any idea on the logic of how do this? Right now, I'm kinda doing something like: <?php session_start(); $expire = time() + 1728000; setcookie('lastvisit', "page1", $expire, "/"); if($_COOKIE['lastvisit'] == "page2") { print" <script> window.location=\"page2.php\" </script> "; } However, my logic kinda gets stuck in a loop, where I can't overwrite the last cookie. Any ideas on how to achieve this? Thanks!
  12. Looks like I totally overlooked this (http://us3.php.net/setcookie) somehow:
  13. Ok, so I think it does have something do with the directory in which the cookie is set. As I previously mentioned, the cookie is being set in /scripts/process_login.php, so I created a test file: /scripts/test.php. This test is able to display the cookie. I guess I'm going to have to do some research on it, and how to set the path.
  14. I'm using: <?php print_r($_COOKIE); ?> Also, I know it's not a browser issue on my end, because I can manually set a cookie at the top of the admin.php page by placing <? setcookie('user', "demoa", $expire); ?> right after session start. And the cookie is being displayed fine with print_r. Do sub-directories have anything to do with it? For example, I'm setting the cookie in scripts/process_login.php and trying to view the cookie in secure/admin.php
  15. That's all the code I'm using in my first post above. :-\
  16. Okay, so I tried making the changes as you suggested, but I am still getting the same issue. Those cookies I am trying to create are not being displayed. Any other suggestions on why this wouldn't be working?
  17. Thanks for the replies. You're right about the encryption, I actually stripped it down just to keep things simple. I'm not in front of a computer right now, but I'll try the change in a bit. Thanks.
  18. Hi All: I've been reading some tutorials on this one and have been attempting to set a cookie when a user logs in successfully and clicks the "Remember Me" checkbox. However, upon a successful login, it appears that the cookie is not being set. Here's my form (simple): <form action="scripts/process_login.php" method="POST"> <input type="text" name="username" maxlength="30" value="" placeholder="Username" /> <input type="password" name="password" maxlength="30" value="" placeholder="Password" /> <span>Remember me?</span><input type="checkbox" name="remember" value="yes" > <input type="submit" value="Login"> </form> And here's my login script: <?php session_start(); session_register('sessUsrFirstName'); session_register('sessUsrLastName'); session_register('username'); session_register('password'); session_register('sessUsrID'); session_register('sessPosition'); session_register('admin'); session_register('sessUsrEmail'); $strLOGONOK = 0; $usrName = $_POST["username"]; $usrPassword = $_POST["password"]; $sql = "SELECT usrID, usrFirst, usrLast, usrPosition, usrAdmin, usrEmail, usrLogin, usrPassword FROM tblUsers"; $sql .=" WHERE (usrPassword = '$usrPassword') AND (usrLogin = '$usrName') AND (usrActive = 1)"; //print($sql); require("../connection.php"); $rs=mysql_db_query($DBname,$sql,$link); if ($rs) { while ($row=mysql_fetch_array($rs)){ $strLOGONOK = 1; $_SESSION['sessUsrFirstName'] = $row['usrFirst']; $_SESSION['sessUsrLastName'] = $row['usrLast']; $_SESSION['sessUsrEmail'] = $row['usrEmail']; $_SESSION['sessUsrID'] = $row["usrID"]; $_SESSION['sessPosition'] = $row['usrPosition']; $_SESSION['admin'] = $row['usrAdmin']; $_SESSION['username'] = $row['usrLogin']; $_SESSION['password'] = $row['usrPassword']; } //end while } // end if else {$strLOGONOK = 0;} mysql_close($link); if ($strLOGONOK == 1){ if($_POST['remember] == "yes") { $expire = time() + 1728000; // Expire in 20 days setcookie('user', "username", $expire); setcookie('pass', "password", $expire); } if($_SESSION['admin'] == 1) { print" <script> window.location=\"../secure/admin.php\" </script> "; } } else { print" <script> window.location=\"../index.php?msg=1\" </script> "; } ?> So then, when a user is redirected to secure/admin.php, I've set at the top of the page for it to display: <?php print_r($_COOKIE); ?> And all it displays is: "Array ( [phpSESSID] => 9e3d0e30fb3c802fba846422eddb0071 )" So, it looks like it's not setting the cookie. Any ideas on how to get this working for me? Thanks!
  19. Thanks thebadbad, your method was very simple and exactly what I needed!
  20. Hi All, One more question: I've tried searching the web for a progress bar that displays the percentage of disk space available, however, all I can find is progress bars for "uploading." Do you know how I might either, a) create my own progress bar, or b) find one that's already been created? I currently have the percentage calculated, i.e. "You are using roughly 32% of your alloted disk space." However, I'd like to display this in a visual way as well. Thanks!
  21. Thanks printf and waynewex, both were exactly what I was looking for!
×
×
  • 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.