Jump to content

elite311

Members
  • Posts

    69
  • Joined

  • Last visited

Everything posted by elite311

  1. Hi, I've been working on making my own FAQ system for my site with PHP & MySQL, I have the SQL displaying properly on the page but I cant seem to figure out how to make it so when the page loads just the questions show and when a question is clicked the answer shows below it. I've read a number of tutorials and when I do get it to work it will only show the answer to the first question when the link is clicked. Here is the code I'm using to display the info from the database: <div id="faqSQL"> <?php foreach($result as $option) { ?> <div class="faq-question"><?php echo wordwrap($option['faqquestion'], 100, "\n", false);?></div> <div class="faq-answer"><?php echo wordwrap($option['faqanswer'], 100, "\n", false);?></div> <?php } ?> </div> If anyone can help it would be much appreciated.
  2. Did some more reading & playing with it and the following code works. function checkdate(input){ var validformat=/^\d{4}\-\d{2}\-\d{2}$/ var returnval=false if (!validformat.test(input.value)) alert("Invalid Date Format. Please correct and submit again.") else{ returnval=true } if (returnval==false) input.select() return returnval }
  3. I'm trying to use java to validate the date format on the input box of my form as YYYY-MM-DD I can get it to work as MM/DD/YYYY but I want the dashes not slashes. Here is what I have come up with but I'm wondering if someone can help me figure out the valid format part or point me to a good tutorial to look at and read. Thanks function checkdate(input){ var validformat=/^\d{4}\-\d{2}\-\d{2}$/ var returnval=false if (!validformat) alert("Invalid Date Format. Please correct and submit again.") else{ returnval=true } if (returnval==false) input.select() return returnval }
  4. I have been reading a lot on this and I can't seem to find the answer, I have a protected directory with .htaccess and I'm wondering if there is a way I can have the PHP script enter the password on the url redirect? Basically I only want the directory to be able to be accessed from my site so I created and SQL database with "id", "site", "url" and then a web form. If the user enters "testsite" and it matchs the "site" in the SQL it redirects the browser to that site. The script works great but the user would have to enter the .htaccess username and password in the popup and I'd like the site to just do that automatically in the background. header('Location: ' . $project_info['url']) I thought I could do something like this header('Location: username:password ' . $project_info['url']) or header('Location: ' . $htuser . $htpass . $project_info['url']) But that doesn't work and I'm not even sure what I'm trying to do is possible.
  5. I'm trying to make what I thought was a simple redirect script but I keep getting error and was wondering if someone can tell me what I have do wrong? I have a database with 3 columns "id", "project", "url" I want to be able to type into a web form the name of the project I'm looking for and if it's found redirect the browser to that project I'm still learning this stuff and cant figure out what I have done wrong and any help would be greatly appreciated. <?php include("project_admin/includes/config.php"); $db = new Database($db_host, $db_username, $db_password, $db_database, $db_table_prefix); $db -> connect(); if ($_POST['findproject']{ $q = $db->mysql_query("SELECT * FROM projects WHERE project LIKE '".$_POST['project']."'"); $r = mysql_fetch_assoc($q); if (mysql_num_rows($q) >= 1){ header('Location:'.$r['url']); }else{ echo "Project Not Found"; } ?>
  6. Thank you very much for the run down on this, as you suggested I have been reading the manual online as we have been going through this thread to get a better idea of what is going on. This has been a huge help and very informative I really appreciate your time.
  7. Hmmm very interesting, so basically by running it the way I am right now the code could work on the first run of the mail handler but not work on subsequent form submissions? if I'm reading what your saying correctly. I'm not familiar with this magic quotes stuff at all as I'm still pretty new to the world of PHP, perhaps some reading is in order. Could you show me the correct way to implement a check on magic quotes into my code?
  8. Thank you very much!! 1 small code addition and everything works great! very good to know for future projects. if($_POST["stripHTML"] == 'true'){ $messageBody = strip_tags($messageBody); $messageBody = stripslashes($messageBody); }
  9. Thanks for the quick reply, I'm not familiar with this at all can I write this directly into the mail handler to disable it on the send mail? or is it something that I need to do on the server?
  10. Hi, I'm having problems with a PHP mail handler and everything seems to be working fine except I get slashes in the message body from the form. If my input is "Please don't delete this" I get "Please don/'t delete this" in the message body, however it is striping the other tags. I'm not sure what is wrong and was hoping for a bit of help to figure this out. Here is the code: <?php $owner_email = $_POST["owner_email"]; $headers = 'From:' . $_POST["email"]; $subject = 'Website contact inquiry from ' . $_POST["name"]; $messageBody = ""; $messageBody .= '<p>------------------ Contact Details ------------------' . '</p>' . "\n"; $messageBody .= '<p>Name: ' . $_POST["name"] . '</p>' . "\n"; $messageBody .= '<p>Email Address: ' . $_POST['email'] . '</p>' . "\n"; $messageBody .= '<p>Phone Number: ' . $_POST['phone'] . '</p>' . "\n"; $messageBody .= '<p>----------------------------------------------------------' . '</p>' . "\n"; $messageBody .= '<br>' . "\n"; $messageBody .= '<p>' . $_POST['message'] . '</p>' . "\n"; if($_POST["stripHTML"] == 'true'){ $messageBody = strip_tags($messageBody); } try{ if(!mail($owner_email, $subject, $messageBody, $headers)){ throw new Exception('mail failed'); }else{ echo 'mail sent'; } }catch(Exception $e){ echo $e->getMessage() ."\n"; } ?>
  11. Ok so after a lot of reading I found a tutorial and have a working locator now. I'm defiantly starting to understand this a little better as I've been working through it but still have a ways to go. You can see it here http://s262833979.onlinehome.us/Dan/postcode/search.php The only hurdle now is it's using the Haversine formula to find the closest location, can someone help me figure out how I can make it show the distance as driving distance and it locate the closest location based on driving distance instead of the Haversine formula? I have attached the file Thanks [attachment deleted by admin]
  12. I've been trying to get this to work for a week now, I can't figure it out. Does anyone know of a good tutorial? I have read a lot of them on store locators but I just want to modify what I already have as I want to build on it after. I really need some help with this, if someone knows how I can change the code above so it will search the database for the closest location to the one I enter instead of me having to enter a 2nd location.
  13. Anyone? I'm really stumped, I just want to have to enter the customers address and it find the closest branch in the date base and then it display how many kilometers away the branch is from the customer
  14. So I'm trying to make a web app for work that allows our reps to enter the customers address then it search a database and return the closest location in the database to the address they entered. I'm pretty new to SQL so any help or tutorials would be great. With a lot of help from tutorials I have it working right now if you enter the 2 address's here's my code and you can see the working page here http://s262833979.onlinehome.us/Dan/servicecall.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <meta name="robots" content="noindex,follow" /> <title>Book A Service Call</title> <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAh2r2YFiBfUkYnPMfobDlIBSZzGBYWmrklI-wZRptp7_OVA51VBTka31gdS-Bl3rNQ2o2ceKs3gSO9g" type="text/javascript"></script> <!-- According to the Google Maps API Terms of Service you are required display a Google map when using the Google Maps API. see: http://code.google.com/apis/maps/terms.html --> <script type="text/javascript"> var geocoder, location1, location2, gDir; function initialize() { geocoder = new GClientGeocoder(); gDir = new GDirections(); GEvent.addListener(gDir, "load", function() { var drivingDistanceMiles = gDir.getDistance().meters / 1609.344; var drivingDistanceKilometers = gDir.getDistance().meters / 1000; document.getElementById('results').innerHTML = '<strong>Customers Location: </strong>' + location1.address + ' (' + location1.lat + ':' + location1.lon + ')<br /><strong>Closest Superior branch: </strong>' + location2.address + ' (' + location2.lat + ':' + location2.lon + ')<br /><strong>Distance to closest Superior branch: </strong>' + drivingDistanceKilometers + ' kilometers'; }); } function showLocation() { geocoder.getLocations(document.forms[0].address1.value, function (response) { if (!response || response.Status.code != 200) { alert("Sorry, we were unable to geocode the first address"); } else { location1 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address}; geocoder.getLocations(document.forms[0].address2.value, function (response) { if (!response || response.Status.code != 200) { alert("Sorry, we were unable to geocode the second address"); } else { location2 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address}; gDir.load('from: ' + location1.address + ' to: ' + location2.address); } }); } }); } </script> </head> <body onload="initialize()"> <form action="#" onsubmit="showLocation(); return false;"> <p> <input type="text" name="address1" value="Address 1" /> <input type="text" name="address2" value="Address 2" /> <input type="submit" value="Search" /> </p> </form> <p id="results"></p> </body> </html> I also set up an SQL database and here is what it looks like : Field Type Length/values id INT 3 store_name VARCHAR 20 street_number VARCHAR 60 city VARCHAR 60 province VARCHAR 10 postal_code VARCHAR 10 latitude FLOAT 10.6 longitude FLOAT 10.6 I have read a lot about the query and came up with this but I'm not sure how to incorporate it into my page, I'm also not sure if this is 100% correct $query = "SELECT `store_name`,`street_number`,`city`,`province`,`postal_code`,`latitude`,`longitude`, ( 3959 * acos( cos( radians($user_lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians($user_long) ) + sin( radians($user_lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM locations ORDER BY distance"; I was really hoping someone could help me figure this out or point me in the right direction. Thanks in advance
  15. Hi, I am having some problems with border-radius.htc that I was hoping someone could help me with. I am using it successfully for some of my site but I have tried to add it in to a few different pages and the top half of the background just disappears, the bottom corners go rounded but it seems like everything else just disappears. here is the code on my page you can see it here - www.autoreflections.ca/club.html <section class="und"> <h2>Birthay Club </h2> <div class="headertop"> <p>Subscribe to our Birthday Club and receive a<span class="style1"> Free Ultimate Automatic Touchless Wash</span> on your Birthday! </p> <p>Auto Reflections will from time to time email you with special offers, promotions, and newsletter.</p> </div> <div class="location"> .....etc....etc.... this Why is it that it works for the location class but not header top? I am calling border raduis with this on the html page: <!--[if IE]><link href="css/ie_style.css" rel="stylesheet" type="text/css" /><![endif]--> My style sheet looks like this: .location{ width:550px; min-height:200px; float:left; padding:20px 20px; -moz-border-radius: 20px; -webkit-border-radius: 20px; -khtml-border-radius: 20px; border-radius:15px; background:#1c1c1c; border:#1c1c1c; } .headertop{ width:550px; min-height:25px; float:left; padding:20px 20px; margin-bottom:20px; -moz-border-radius: 20px; -webkit-border-radius: 20px; -khtml-border-radius: 20px; border-radius:15px; background:#1c1c1c; border:#1c1c1c; } And my IE style sheet looks like this: #content,section,aside,.extra-wrap {zoom:1;} .boxes .box{ behavior:url(js/border-radius.htc); } .boxes .washcard{ behavior:url(js/border-radius.htc); } .boxes .washpass{ behavior:url(js/border-radius.htc); } .headertop{ behavior:url(js/border-radius.htc); } .location{ behavior:url(js/border-radius.htc); }
  16. Looks like I didn't even need to ask this question, sorry. After doing some more reading I found that adding in: float:left; To my code and then a few margins I got everything to line up perfectly. So for anyone else that might have this same problem of get things to line up properly my code ended up like this: #reloadcard { display: block; width: 136px; height: 57.5px; float:left; margin-left: 13px; margin-top: 20px; margin-bottom: 20px; background: url("../images/reloadcard.gif") no-repeat 0 0; } #reloadcard:hover { background-position: 0 -58px; } #reloadcard span { position: absolute; top: -999em; } #checkbalance { display: block; width: 138px; height: 57.5px; float:left; margin-top: 20px; margin-bottom: 20px; background: url("../images/checkbalance.gif") no-repeat 0 0; } #checkbalance:hover { background-position: 0 -58px; } #checkbalance span { position: absolute; top: -999em; }
  17. Ok so I feel stupid now! I fixed the image rollover problem. Turns out you need to upload the correct image for it to work...WOW I feel dumb. I still haven't figured out how to align the 2 buttom images but I'll keep playing with it.
  18. I'm pretty new to the world of CSS but love how it works, I have been doing a lot of reading about it and how to implement it into my site. I think I'm getting pretty good at at it.... and then I can't figure this problem out which seems so simple. I'm trying to use CSS to make 3 buttons with rollovers. This is my code: /*==== BUTTONS =====*/ #applyonline { display: block; width: 144px; height: 57.5px; background: url("../images/applyonline.gif") no-repeat 0 0; } #applyonline:hover { background-position: 0 -58px; } #applyonline span { position: absolute; top: -999em; } #reloadcard { display: block; width: 136px; height: 58px; background: url("../images/reloadcard.gif") no-repeat 0 0; } #reloadcard:hover { background-position: 0 -58px; } #reloadcard span { position: absolute; top: -999em; } #checkbalance { display: block; width: 138px; height: 57.5px; background: url("../images/checkbalance.gif") no-repeat 0 0; } #checkbalance:hover { background-position: 0 -58px; } #checkbalance span { position: absolute; top: -999em; } The weird part is the apply online button works great but the other 2 buttons don't. When I rollover the re-load card and check balance button they disappear. Here's the link to my site http://s262833979.onlinehome.us/AR2011/washcard.html The other problem is I can't figure out how to line the 2 images up side by side. Here's the code on my HTML page: <div class="colum"> <div align="left"><img src="images/outline-1.png" width="299" height="11"></div> <div align="left"><img src="images/washcard.jpg" alt="" width="298" height="141" class="p2"></div> <div align="center"> <div align="center"><a id="applyonline" href="wcardorder.html" title="Apply Online"><span>Apply Online</span></a> </div> <div align="center"><a id="reloadcard" href="wcardreload.php" title="Re-load Card"><span>Re-load Card</span></a> <a id="checkbalance" href="wcardbalance.php" title="Check Balance"><span>Check Balance</span></a> </div> </p> </div> </div> Can anyone help me fix this? I would really appreciate it because I just cant seem to figure out what is going wrong.
  19. Hello, I am fairly new to the world of we programing and I'm hoping someone can help me or at least point me in the right direction. I am working on a project for my company's customer service team, basically I am using google maps to allow the CSR to enter to locations and get the distance between the locations. I'm trying to upgrade this system and automate it some. Right now the CSR must enter both locations, the customers location(city & province) and out location (city & province) what I'm trying to accomplish is only getting the CSR to enter the customers location and then have the system search a sql database of all our branches to find the closest one and then return the result with the driving distance. Our company books service calls based on a zone system, example: zone 1: 0 to 50kms = $129 zone 2: 50 to 100kms = $173.50 etc So I want to automate the search system to find the closest branch and display the driving distance in kms as well as show the price of the service call based on how many kms away it is. I have done a lot of reading of tutorials and have been trying to get this to work for a while but I'm having all kinds of trouble. My code right now is: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <meta name="robots" content="noindex,follow" /> <title>Book A Service Call</title> <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAh2r2YFiBfUkYnPMfobDlIBSZzGBYWmrklI-wZRptp7_OVA51VBTka31gdS-Bl3rNQ2o2ceKs3gSO9g" type="text/javascript"></script> <!-- According to the Google Maps API Terms of Service you are required display a Google map when using the Google Maps API. see: http://code.google.com/apis/maps/terms.html --> <script type="text/javascript"> var geocoder, location1, location2, gDir; function initialize() { geocoder = new GClientGeocoder(); gDir = new GDirections(); GEvent.addListener(gDir, "load", function() { var drivingDistanceMiles = gDir.getDistance().meters / 1609.344; var drivingDistanceKilometers = gDir.getDistance().meters / 1000; document.getElementById('results').innerHTML = '<strong>Address 1: </strong>' + location1.address + ' (' + location1.lat + ':' + location1.lon + ')<br /><strong>Address 2: </strong>' + location2.address + ' (' + location2.lat + ':' + location2.lon + ')<br /><strong>Driving Distance: </strong>' + drivingDistanceMiles + ' miles (or ' + drivingDistanceKilometers + ' kilometers)'; }); } function showLocation() { geocoder.getLocations(document.forms[0].address1.value, function (response) { if (!response || response.Status.code != 200) { alert("Sorry, we were unable to geocode the first address"); } else { location1 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address}; geocoder.getLocations(document.forms[0].address2.value, function (response) { if (!response || response.Status.code != 200) { alert("Sorry, we were unable to geocode the second address"); } else { location2 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address}; gDir.load('from: ' + location1.address + ' to: ' + location2.address); } }); } }); } </script> </head> <body onload="initialize()"> <form action="#" onsubmit="showLocation(); return false;"> <p> <input type="text" name="address1" value="Address 1" /> <input type="text" name="address2" value="Address 2" /> <input type="submit" value="Search" /> </p> </form> <p id="results"></p> </body> </html> I have created an SQL table (with some help from some tutorials) to enter all of the branch loactions and it looks like this: `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `name` VARCHAR( 60 ) NOT NULL , `address` VARCHAR( 80 ) NOT NULL , `lat` FLOAT( 10, 6 ) NOT NULL , `lng` FLOAT( 10, 6 ) NOT NULL The first part works fine and does what I want but I cant figure out how to get it to search an SQL database instead of having to enter the location manually. You can see my working code so far at http://s262833979.onlinehome.us/Dan/servicecall.html Can anyone help me figure out how to do this? I am using PHP 5 and MySQL 5.0 and Google Maps API Any help would be greatly appreciated as I'm completely stumped!
×
×
  • 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.