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"; } ?>
×
×
  • 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.