Jump to content


  • Posts

  • Joined

  • Last visited


Profile Information

  • Gender

blepblep's Achievements


Newbie (1/5)



  1. Where do I put that? In here? function sanitize_data($data) { $data = mysql_real_escape_string(trim($data)); return $data; } $post = filter_var_array($_POST,FILTER_SANITIZE_STRING); $post = array(); foreach($_POST as $key =>$value){ $post[$key] = sanitize_data($value);
  2. Hi, wondering can anyone help me here. I have the following function sanitize - function sanitize_data($data) { $data = mysql_real_escape_string(trim($data)); } $post = array(); foreach($_POST as $key =>$value){ $post[$key] = sanitize_data($value); I need to change it to this function_sanitize - function sanitize_data() { foreach($_POST as $name => $value) { if (is_array($value)) { for ($i = 0; $i < count($value); $i++) { $value[$i] = htmlspecialchars($value[$i], ENT_QUOTES); $value[$i] = stripslashes($value[$i]); $value[$i] = mysql_real_escape_string($value[$i]); } $_POST[$name] = $value; } else { $_POST[$name] = htmlspecialchars($value, ENT_QUOTES); $_POST[$name] = stripslashes($_POST[$name]); $_POST[$name] = mysql_real_escape_string($_POST[$name]); } } } sanitize_data(); The reason I need to do this is because a user fills in a text field, but I get an SQL error when someone enters a special character like ' % ^ & " etc. The second function_sanitize I posted works in my other forms but for this one it doesnt. Would anyone have any ideas how I can implement the second function into the first one? Or a way to enter special characters. Thanks
  3. Ahhh ok, I see what you mean. Thanks for that. Is there a way I can do it like this? And then, depending on what is selected, send an email to that address? Am I wrong in saying how you have it done for me, it will display 3 links that I can click on each time, so instead of just showing one link it will show however many is created?
  4. I can't use links like that. The Review Forum and Review ID I posted in the screenshot from search result so they are different each time. Could you explain this to me please - <td><a href="sendMomEmail.php?sendemail=TCCNOSS">Send e-mail to TC CNOSS</a></td></tr> How will the above work if it is a different forum to TC CNOSS? As there is 9 possible ones and I don't no how that would work with the sendemail = TCCNOSS part? These are the different forums - TC CNOSS, TC PM, TC OSS RC, TC Arch Board, TC TOR, TC PF, TC WRAN, TC GRAN, TC Navigator. I am wondering how could I do it the way you described but instead of naming the link TC CNOSS as this could be different depending on what Review Forum it is..
  5. It is incredibly messy, the first half of it was coded by myself and the second by someone else. Heres a snippet of mine with the code getting the reviewForum. The reviewForum is what I want to send the email to, so instead of having a drop down menu that contains the 9 forums, I just want to have some sort of condition that checks if it is TC CNOSS send an email to tcnoss@email.com, if it is TC TOR send an email to tctor@email.com etc etc.. Is this possible do you think? <tr> <th>Review Forum</th> </tr> <td>" . custOut($row['reviewForum']) . "</td> My button code - <td> <form id='sendEmail' action = \"sendMomEmail.php\" method = \"post\"> <input type = \"submit\" value = \"Send email for approval\" style='display:inline;' onclick =\"sendMomEmail.php\"> </form> </td>
  6. This was the original idea I had in my head as to how I was going to code it but it doesnt work - $email_location = $_POST['location']; // the value from your form if($email_location == "Atlanta") { // a form value and a location $your_email = "atlanta@email.com"; // the email for that location } else if ($email_location == "Colorado") { $your_email = "colorado@email.com"; } else if ($email_location == "Virginia") { $your_email = "virginia@email.com"; } else if ($email_location == "Kansas City") { $your_email = "kansas@email.com"; } else { // if no one is good, send it to this email $your_email = "standard@email.com"; }
  7. What I want to do is to send an email to an address based on a forum. There is 9 forums to choose from in a drop down menu but these are hard coded in. Sorry I shouldn't have set the variable of the post outside the if statement. My bad sorry! I dont no how I can send an email based on a certain form that the user selects.
  8. Hi, wondering could anyone help me here again. I have been asked to implement a email feature depending on a selection. I've seen plenty of examples online about doing it from a drop down, but I need to do it without a drop down menu. The user has 9 forms to choose from. Each of these forms has a name, say TC CNOSS, TC OSS RC etc for example (These forms are selected from a drop down menu but this drop down menu is not populated from the database, it is hard coded). When the user fills in a form, they get an ID which they enter to a search menu. This returns the form they filled in, but with a small bit of extra information needing to be filled in. After they fill in this extra bit of information, I have a button that says 'Send to X for approval'. This button goes to another page which performs the below code - Now the part I am stuck at is, how do I send an email to say TC CNOSS if the user is filling in a form of TC CNOSS? I just want the email to say 'TC Number 10 needs to be approved' and then include a link to my site. <?php $reviewForum = $post['reviewForum']; if(isset($_POST['submit'])) { if ($post['reviewForum'] = 'TC CNOSS') { // The message $message = "Line 1\nLine 2\nLine 3"; // In case any of our lines are larger than 70 characters, we should use wordwrap() $message = wordwrap($message, 70); // Send mail('testemail@test.com', 'My Subject', $message); } } ?> Thanks to anyone who can help, if there is any more info needed just ask.
  9. @smoseley - It's just how it is. I'm only a student doing work placement here so I can't really argue with what work I'm given you know? I understand where your coming from and it does seem pointless to me too but it has to be done :-\ They want everything done for them, in their own words "It shouldn't take more than 3 or 4 clicks to have something done/get somewhere." @ManiacCan, see above. I'm only here till 31st August though so its not too bad. Not at all what I thought it would be when I first came in given the massive size of the company and all its employees around the world.
  10. Sorry for the late reply Barand, I was finished work on Friday. The above works perfectly, thank you! I have another question to ask you about, sorry See the screenshot below, is there a way to widen the document itself so all of the information is visible? See how on the right here the column gets very narrow? The part where it is narrow is the last column - EDIT - Sorry, its a Monday morning I just put some of the results into another table so their on the next row.
  11. I've come across a bit of a problem and I have a feeling I no how to fix it but it is a longer way, but I am wondering is there a way I solve it without creating more queries. I have another row underneath my first results and it is viewable when I click expand. I am trying to do the same thing in Word but without the expand, so just have it displaying but on another row. This is how it is on the website at the moment - My code at the moment is like this - echo "<h1>TC Tool Minutes of Meeting</h1>"; echo "<table>"; // header row echo "<tr> <th>Review Forum</th> <th>Review ID</th> <th>Document Title</th> <th>Document Number</th> <th>Document Type</th> <th>Project Name</th> <th>Author Name</th> <th>Chairperson</th> <tr>"; while ($user_array = mysql_fetch_assoc($qry)) { // data row echo //"tr> <- Puts a space under Review forum and its value. " <td>{$user_array['reviewForum']}</td> <td>{$user_array['reviewId']}</td> <td>{$user_array['docTitle']}</td> <td>{$user_array['docNumber']}</td> <td>{$user_array['docType']}</td> <td>{$user_array['projectName']}</td> <td>{$user_array['authorName']}</td> <td>{$user_array['chairPerson']}</td> "; } echo "</table>"; echo "<table>"; echo "<tr> <th>Revision</th> <th>CDM Link</th> <th>Main Requirement ID</th> <th>Mars Link</th> <th>Checklist Link</th> <th>Link Internal 1/3</th> <th>Impacted Products</th> <th>Scope</th> <th>Impacted Products 2</th> <th>Review Class</th> <th>Review Type</th> <th>Earliest Date</th> <th>Latest Date</th> <th>Previous TC Reviews</th> <th>Required Attendees</th> <th>Optional List</th> <th>Information Only</th> <th>Review Duration</th> <th>Document Abstract</th> </tr>"; while ($user_array = mysql_fetch_assoc($qry)) { // data row echo //"<tr> <- Puts a space under Review forum and its value. " <td>{$user_array['revision']}</td> <td>{$user_array['cdmLink']}</td> <td>{$user_array['mainReqId']}</td> <td>{$user_array['marsLink']}</td> <td>{$user_array['checklistLink']}</td> <td>{$user_array['linkInternalOneThird']}</td> <td>{$user_array['impactedProducts']}</td> <td>{$user_array['abstract']}</td> <td>{$user_array['impactedProducts2']}</td> <td>{$user_array['reviewClass']}</td> <td>{$user_array['reviewType']}</td> <td>{$user_array['earliestDate']}</td> <td>{$user_array['latestDate']}</td> <td>{$user_array['previousTcReviews']}</td> <td>{$user_array['requiredAttendees']}</td> <td>{$user_array['optionalAttendees']}</td> <td>{$user_array['informationOnly']}</td> <td>{$user_array['reviewDuration']}</td> <td>{$user_array['docAbstract']}</td> "; } echo "</table>"; And I get this in word when the above code runs - So it is calling the mysql_fetch_array twice. Is there a way I can get it to run without creating another query and inserting it into the second table? Even have the second results inside the while loop but printing out in Word the same as my web page?
  12. Thanks a million Barand, I really appreciate it. I'm a java/c++ programmer in college and I'm currently on work placement. And where I am working I needed to learn HTML, CSS, JavaScript and PHP over the past few months, so everyday is a learning day really!
  13. Thank you so much Barand, that is exactly how I am wanting to display it!! Here is my headers: Review Forum, Review ID, Document Title, Document Number, Document Type, Project Name, Author Name, Chairperson. I have a question, how you have coded it to display is fine, but when I try to add another row such as Review Forum, it appears inside the Review ID like this - Is there a way I could have it lining up beside each other so they will appear like this -(Color doesnt matter but just the aligning right beside each other is what I am after) And my code for the first picture - echo "<h1>Reviews</h1>"; echo "<table CELLPADDING=10 border = 0 >"; echo "<tr> <th>Review Forum</th> <tr>"; echo "<table CELLPADDING=10 border = 0 >"; echo "<tr> <th>Review ID</th> <tr>"; while ($user_array = mysql_fetch_assoc($qry)) { echo "<tr> <td>{$user_array['reviewForum']}</td> </tr>"; echo "<tr> <td>{$user_array['reviewId']}</td> </tr>"; } echo "</table>";
  14. Thanks Barand. I understand the CSS side of what you posted, and the connecting to database part but what I dont no how to do is get the data from my query and insert it to a certain position IE under a header? Say I have Review ID as a header then under that I want the review id, I don't no how to put it in under there. Sorry aswell but in the code what do you mean easy data tables? include("baaGrid.php"); // easy data tables Here is what I have so far - mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $user_result = "SELECT review.*, mom.*, action.*, remark.* FROM review LEFT JOIN mom on review.reviewId = mom.reviewId LEFT JOIN remark on review.reviewId = remark.reviewId LEFT JOIN action on review.reviewID = action.reviewId WHERE review.reviewId IN ( ".$_POST['reviewIds']." )"; $qry = mysql_query($user_result) OR die(mysql_error()); $user_array = mysql_fetch_assoc($qry); echo "<center>"; echo "<table CELLPADDING=10 border = 0 >"; echo "<tr>"; echo "<th>Review ID</th> <tr>".$user_array['reviewId']."</tr>"; echo "</tr>"; echo "</table>"; mysql_close(); ?> And it takes the data from the DB and shows it on screen. This isnt much use though as ideally I want it downloading automatically to a word document. Thanks for the help so far! EDIT - I have added this to the file - header("Expires: 0"); header("Cache-control: private"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Description: File Transfer"); header("Content-Type: application/vnd.ms-excel"); header("Content-disposition: attachment; filename=export.doc"); And it downloads straight away to a word doc and opens it also, woo! Can anyone tell me if that is a ok way to go about it or should i do it differently?
  15. I don't no how to do that. This is all new to me so I am learning as I'm going along which is why what I am asking may seem stupid to people on here. Edit - Would it be something like in this link? http://forums.devshed.com/php-development-5/display-results-from-query-in-html-table-4095.html
  • 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.