Jump to content

elmas156

Members
  • Posts

    276
  • Joined

  • Last visited

Everything posted by elmas156

  1. Thanks for the reply. Do you know of anywhere I can find a good tutorial on how to do this? I don't use javascript much at all and I am very limited in my knowledge in it. Thanks again for your help.
  2. I know that there is a way to this with javascript, but I don't know how it would work. I am much more familiar with php so I figured I would ask here to see if anyone might have a good php solution. I'm trying to have a form text field display depending on whether or not the user checks a specific box, but I'm not sure where to start. I've searched around but I didn't find anything that would help. Basically I want to have a checkbox that asks if the user would like to link their account to an email address. If the checkbox is selected, a textbox will then appear on the page for them to enter an email address. Can anyone point me in the right direction on where to start? Thanks for your help.
  3. Hello everyone, I'm sitting here in a position where I can't work on my site or test any code, but my mind is racing about what I can do to solve a particular problem that I have. I won't get into the problem because it would take more time to type than I have right now, but I have an idea for a simple solution, just not sure if it will work or not. So, here's my question: Is it possible to have multiple session variables during a session? Such as: $email=$_SESSION['email']; $user=$_SESSION['userid']; If this is possible, my problem is solved (I think)... otherwise, I have to keep thinking about it. Thanks for any help!
  4. Got it working perfectly. Thanks for your help!
  5. Also, the second connection is INSIDE the loop because part of the database name is the client's account number. So I'm trying to use the loop to get each client's account number to use so the database name in the second connection is set to "dbase_$acct". Any ideas to get around this?
  6. Yes, they ARE on the same server and they ARE accessed with the same username/password.
  7. Hello everyone. I have a site that serves multiple clients, each of which have their own database. For each client there are a few people who I have to send reports to each day of the activity that occurred on their account. Instead of creating a different script to run individually as a cron job for each client, I decided to create one that will run each day and will handle sending each clients report to every person on the list to receive the reports. To do this, I'm going to have to connect to two databases at the same time to get each client's account number from a general database, then get the activity on each client's account database to send the reports. I'm pretty sure I'm on the right track, but I'm still having problems. Any help would be greatly appreciated. Here's what I have so far: This code returns "Table 'dbase_admin.dbase_admin' doesn't exist" <?php $db1_user = "uname"; // Username $db1_pass = "*****"; // Password $db1_database = "dbase_admin"; // Database Name $db1_host = "localhost"; // Server Hostname $db1_connect = mysql_connect ($db1_host, $db1_user, $db1_pass); // Connects to the database. $db1_select = mysql_select_db ($db1_database); // Selects the database. $clientresult = mysql_query("SELECT `acct_number`,`school` FROM `accounts`, $db1_database") or die (mysql_error()); while ($clientrow = mysql_fetch_row($clientresult)) { $acct = $clientrow[0]; $school = $clientrow[1]; $db2_user = "uname"; // Username $db2_pass = "*****"; // Password $db2_database = "dbase_$acct"; // Database Name $db2_host = "localhost"; // Server Hostname $db2_connect = mysql_connect ($db2_host, $db2_user, $db2_pass); // Connects to the database. $db2_select = mysql_select_db ($db2_database); // Selects the database. $result3 = mysql_query("'SELECT * FROM allmsgs WHERE reported = 'n', $db2_database") or die (mysql_error()); $row3 = mysql_fetch_row($result3); $cdate = date('m-d-Y'); if ($row3 > 0) { $result = mysql_query("SELECT `studentname`,`staffname`,`subject`,`message`,`date` FROM allmsgs WHERE reported = 'n' ORDER BY `messid` ASC", $db2_database); $result2 = mysql_query("SELECT `prefix`,`lname`,`email` FROM admin WHERE send = 'y', $db2_database"); $eachprefix = ''; $eachlname = ''; $eachemail = ''; while ($row2 = mysql_fetch_row($result2)) { $prefix = $row2[0]; $lname = $row2[1]; $email = $row2[2]; $eachprefix .= "$prefix, "; $eachlname .= "$lname, "; $eachemail .= "$email, "; } $sendto = "$eachemail"; $emailsubject = "$school Message Report For $cdate."; $eachmessage = ''; while ($row = mysql_fetch_row($result)) { $studentname = $row[0]; $staffname = $row[1]; $subject = $row[2]; $message = $row[3]; $saveddatetime = $row[4]; $message2 = nl2br("$message"); $eachmessage .= "<p> <table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td align=\"left\"> <hr width=\"500\" /> <hr width=\"500\" /> <font size=\"+1\"><strong>New Message:</strong></font><br> <hr width=\"500\" /> <hr width=\"500\" /><br /> To: $staffname<br /> From: $studentname<br /> On $saveddatetime<br> <br /> Subject: $subject<br> <br /> $message2<br> <br /> </td> </tr> </table> </p>"; } $emailmessage = "<html> <body> <p> <table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td> <strong>$eachprefix $eachlname, <p>Here is a list of the messages that have been exchanged in the last 24 hours using the mysite.com system.</p></strong> </td> </tr> </table> </p> <br \> $eachmessage </body> </html>"; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'From: mysite.com Report <support@mysite.com>' . "\r\n"; // Tells the mail server who the email is from $fromaddress = '-fsupport@mysite.com'; // Mail it mail($sendto, $emailsubject, $emailmessage, $headers, $fromaddress); mysql_query("UPDATE `allmsgs` SET `reported` = 'y' WHERE `reported` = 'n'"); } } ?>
  8. Hello everyone, I'm working on an account update page where users can update their email address, password, or security question/answer as desired. The way I currently have it set up is so that only the information that the user enters will be updated in the database. So if they only enter a new email address, the email field in the database is updated and all other fields are left as is. I'm also trying to set a javascript even handler (onUnload) depending on whether or not anything was updated. When their info is successfully updated, I want to alert the user accordingly, as well as when no information was updated. To do this, I have a variable "$updated" that is set at "false" by default and is supposed to be set to "true" when something is updated and "none" when nothing is updated. The form and mysql commands are working and the correct fields are being updated as expected. The problem that I'm having is the $updated variable is not being set correctly and is ALWAYS being set to "true", even when it is expect to be set to "none." Here's the code that I have: <?php function safe($value){ return mysql_real_escape_string($value); } $updated = "false"; if (isset($_POST['submit'])) { // If the form has been submitted. $newemail = $_POST['newemail']; $pword1 = $_POST['pword']; $question = safe($_POST['question']); $answer = safe($_POST['answer']); $updated = $_POST['updated']; $pword = md5($pword1); $q = mysql_query("SELECT * FROM `signin` WHERE email = '$newemail'") or die (mysql_error()); $r = mysql_num_rows($q); // Checks to see if anything is in the db. if ($r == 1 && $email == $newemail) { $noemail = "true"; } elseif ($r == 0) { $noemail = "true"; } else { $noemail = "false"; } if ($newemail != "" && $pword1 == "" && $question == "0") { if ($noemail == "true") { mysql_query("UPDATE `signin` SET `email` = '$newemail' WHERE email = '$email'") or die (mysql_error()); $_SESSION['email'] = $newemail; $updated = "true"; } } elseif ($newemail == "" && $pword1 != "" && $question == "0") { mysql_query("UPDATE `signin` SET `pword` = '$pword' WHERE email = '$email'") or die (mysql_error()); $updated = "true"; } elseif ($newemail == "" && $pword1 == "" && $question != "0") { mysql_query("UPDATE `signin` SET `question` = '$question',`answer` = '$answer' WHERE email = '$email'") or die (mysql_error()); $updated = "true"; } elseif ($newemail != "" && $pword1 != "" && $question == "0") { if ($noemail == "true") { mysql_query("UPDATE `signin` SET `email` = '$newemail',`pword` = '$pword' WHERE email = '$email'") or die (mysql_error()); $_SESSION['email'] = $newemail; $updated = "true"; } } elseif ($newemail != "" && $pword1 == "" && $question != "0") { if ($noemail == "true") { mysql_query("UPDATE `signin` SET `email` = '$newemail',`question` = '$question',`answer` = '$answer' WHERE email = '$email'") or die (mysql_error()); $_SESSION['email'] = $newemail; $updated = "true"; } } elseif ($newemail == "" && $pword1 != "" && $question != "0") { mysql_query("UPDATE `signin` SET `pword` = '$pword',`question` = '$question',`answer` = '$answer' WHERE email = '$email'") or die (mysql_error()); $updated = "true"; } elseif ($newemail != "" && $pword1 != "" && $question != "0") { if ($noemail == "true") { mysql_query("UPDATE `signin` SET `email` = '$newemail',`pword` = '$pword',`question` = '$question',`answer` = '$answer' WHERE email = '$email'") or die (mysql_error()); $_SESSION['email'] = $newemail; $updated = "true"; } } else { $updated == "none"; } } ?> //This is where the event handler (onUnload) is set according to what has occurred in the code above <?php if (isset($_POST['submit']) && $updated = "true") { echo "<body onUnload=\"alert('Your information has been successfully updated.')\">"; } elseif (isset($_POST['submit']) && $updated = "false") { echo "<body onUnload=\"alert('There have been no updates made to your account information.')\">"; } else { echo "<body>"; } ?> Can anyone see a problem with this and why the $updated variable is not being set as expected. Any ideas on a better way to accomplish what I want to do? Thanks in advance for anyone's help!
  9. Haha... We all make them, some are just better at finding them than others. The ones that I hate the most are the ones where there's not really any problem in the code, so you get no errors... just the wrong output, so you're left trying to trace your steps, usually to find that the only problem was yourself! Funny how something works right when you do it right...
  10. I just found the problem! I finally just broke down and rewrote the whole section of code and I realized that I was pulling info from the "signin" table when I should have been getting it from the "staff" table! Basically, I was querying the wrong information. Silly mistakes cost me so much time! Thanks for your help.
  11. phpMyAdmin is how I view the database and its contents.
  12. I'm having a problem that I didn't seem to have in the past... for some reason, it just popped up... or maybe I'm just noticing it. Anyway, I this in a field in a mysql database: "Here's a test." When I query the database and echo the text to the page with this code: $result = mysql_query("SELECT question FROM signin WHERE email = '$email'") or die (mysql_error()); $row = mysql_fetch_row($result); $test = $row[0]; echo $test; This is the result: "Heres a test." Any ideas on why the apostrophe is not being displayed and how to fix it? I'm stumped. Thanks for any help.
  13. Wow! It's amazing how something works when you do it right! Thanks for your help.
  14. But I am using the variables in a mysql query. I'm inserting the data, then sending the user, and administrators an email with the same data. That's how I know that it inserts properly into the database but not in an email.
  15. Yes, I should have posted this originally, but here is the actual mail function that I'm using: $subject2 = nl2br("$subject"); $message2 = nl2br("$message"); $sendto1 = "$email"; $emailsubject1 = "Message Sent"; $emailmessage1 = "<html> <body> <table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td> This message is to notify you that you have been contacted through the messaging system. A copy of the message has been included below.</p> <strong>Subject: \"$subject12\"</strong> <p>$message2</p> <hr width=\"500\" /><br /> Thank you! </td> </tr> </table> </body> </html>"; // To send HTML mail, the Content-type header must be set $headers1 = 'MIME-Version: 1.0' . "\r\n"; $headers1 .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers1 .= 'From: CaresAbout.us <support@CaresAbout.us>' . "\r\n"; // Tells the mail server who the email is from $fromaddress1 = '-fsupport@caresabout.us'; // Mail it mail($sendto1, $emailsubject1, $emailmessage1, $headers1, $fromaddress1);
  16. Here's the code that I have: <?php if (get_magic_quotes_gpc()) { function undoMagicQuotes($array, $topLevel=true) { $newArray = array(); foreach($array as $key => $value) { if (!$topLevel) { $key = stripslashes($key); } if (is_array($value)) { $newArray[$key] = undoMagicQuotes($value, false); } else { $newArray[$key] = stripslashes($value); } } return $newArray; } $_GET = undoMagicQuotes($_GET); $_POST = undoMagicQuotes($_POST); $_COOKIE = undoMagicQuotes($_COOKIE); $_REQUEST = undoMagicQuotes($_REQUEST); } function safe($value){ return mysql_real_escape_string($value); } $subject1 = "It's just a test."; $message1 = // $subject1 and message1 are actually submitted from a form on the page... "Here's a test. // so this section would really be $subject = safe($_POST['subject']); same w/ message // I did it this way to simplify... I'm pretty sure it would be the same either way. Thanks, Me"; // this is what is typed in the text area of the form. $subject = safe($subject1); $message = safe($message1); ?> When these variables are mailed using php mail(), they display like this: Subject: It\'s just a test. Message: Here\'s a test.\r\n\r\nThanks,\r\nMe When they are inserted into a database, they are inserted correctly, as they were typed. My question is this: Is there a way to mail these and have them display correctly? Should I just insert them into the database, then select them again to mail? Thanks for any help.
  17. Awesome, thanks! I think problem is solved... until the next one comes along
  18. Hello everyone, With the recent time change, I found a new problem with my code. I think I have it fixed by utilizing the "date_default_timezone_set()" function, but I have a question. Does this php time/date function automatically account for daylight savings time, is it something that will have to be adjusted in my code? I think I can figure out how to adjust it if it's needed, but I don't want to have to do the work if it is updated automatically. Thanks for any help.
  19. For anyone else who might have the same problem, I think I've got it figured out: When using php to include files from another folder, you use "../" to go up one step in your folders. So it will work exactly the way I have described it above. For some reason, when using a sub-domain, you cannot use the "../" method with html to link images or .css file, you have to use the entire url. So to link to the css file you have to do it this way: <link href="http://www.mysite.com/ClientsFolder/client1/include-folder/style.css" rel="sytlesheet" type="text/css" /> That's the way it is working for me anyway.
  20. Hello everyone, I have a site where the folders are set up in this arrangement: _ ClientsFolder - client1 - | page-folder - pages are here (index.php) | | image-folder - images here | |_include-folder - style.css and database connections here _ client2 - | page-folder - pages are here (index.php) | | image-folder - images here | |_include-folder - style.css and database connections here PageIncludeFolder - include pages here (index.inc.php) The reason my folders are set up this way is because multiple clients will be using my site, but each client will have a customized sub-domain, yet all the code on the pages will be the same. All of the pages for the clients site are placed in ClientsFolder/client1/page-folder. Each page in this folder is a page that simply includes an entire page from the PageIncludeFolder. For example: ClientsFolder/client1/page-folder/index.php and ClientsFolder/client2/page-folder/index.php are exactly the same, file, which simply has the following code: <?php include("../../../PageIncludeFolder/index.inc.php"); ?> The reason for this is so that I can easily modify all the client sites by only modifying the files that are in the PageIncludeFolder. (Trying to work smarter, not harder!) The images, style.css, and script.js files are called from the index.inc.php, which is included on the index.php page. For example, style.css is located at ClientsFolder/client1/page-folder/include-folder/style.css. So to link to the .css file, I have the following code in the index.inc.php file: <link href="../include-folder/style.css" rel="sytlesheet" type="text/css" /> And images are linked using code similar to this: <img src="../image-folder/image.jpg" /> Now, when I visit the index.php page by entering the entire url (http://www.mysite.com/ClientsFolder/client1/page-folder/index.php) everything works perfectly. However, as I stated, each client is being set up with a sub-domain. Client 1 has the sub-domain of http://client1/mysite.com, which is pointed to http://www.mysite.com/ClientsFolder/client1/page-folder/index.php. When I try to visit client 1's site using the sub-domain, the index.inc.php page is included perfectly, but the images and the style.css files are not being linked. I know this is kind of confusing, but as you can probably tell, I have spent many, many hours putting this together and now I need help to figure out what is wrong and why certain files are not linking properly ONLY when the page is visited using the sub-domain. ANY help or suggestions are GREATLY appreciated! Thanks everyone!
  21. Got it. Thanks for everyone's help. I have everything working smoothly now. I would mark this as solved now but I don't see a link for that anymore... wonder why it was removed???
  22. Yes, my code is being executed now. I went back to the basic script that I started with and I am tweaking each section of it to try to get it to do what I want. When I tweak a section and it stops working, I know that's what was causing my code to fail. It turns out that the From: header and the fifth parameter was causing the failure when I was trying to use $email within them. Now I'm just trying to get the emails to display the user's info as the reply to info.
×
×
  • 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.