Log in

View Full Version : Sendmail\Database related questions



TimFA
01-11-2008, 12:40 AM
I have a few questions. When working with a sendmail.php or whatever you want to call it how would you check for HTML tags? I can't find a functions to do it... I suppose just looking for "<" and ">" would work, would it not? Anyways next question. I don't understand this whole database thing, I know how to access it, and all that. What I don't get is how you actually look at a section of data. Like it recently hit me what fgets() does, great end at the line break...but what if I wanted it to begin the second line down, or third, etc? I just don't get it...:confused: Well, time to wait for a reply.

-Tim

boogyman
01-11-2008, 02:05 PM
I have a few questions. When working with a sendmail.php or whatever you want to call it how would you check for HTML tags? I can't find a functions to do it... I suppose just looking for "<" and ">" would work, would it not?
are the tags a part of the user input.... eg something the user enters into a text input / textarea field?
what exactly do you want to do with the html tags?
you could replace the left and right signs with their unicode equivalent, which would prevent them from causing any harm.


str_replace('<', '&lt;', $tring);
str_replace('>','&gt;', $tring);




I don't understand this whole database thing, I know how to access it, and all that. What I don't get is how you actually look at a section of data. Like it recently hit me what fgets() does, great end at the line break...but what if I wanted it to begin the second line down, or third, etc? I just don't get it
if you wish to insert line breaks before the start of a new html field then that would require a couple of things. First you would need to know how you would like to delimit (separate) the content, then you would need to know how far down you would like to push everything. This can be done at two times. it can be done before you insert them into the database, or you can do it after you pull from the database.
research the implode() and explode() methods on http://www.php.net

TimFA
01-11-2008, 04:17 PM
No harm no foul I suppose. Yes, it will be processing 3 fields. A 2 textboxs, and 1 textarea. I had nothing specific in mind about what to do with them, just somehow prevent them from doing anything.



if you wish to insert line breaks before the start of a new html field then that would require a couple of things. First you would need to know how you would like to delimit (separate) the content, then you would need to know how far down you would like to push everything. This can be done at two times. it can be done before you insert them into the database, or you can do it after you pull from the database.
research the implode() and explode() methods on http://www.php.net


Everything I've ever looked at on php.net I couldn't understand, I found their examples...well, crappy. I always had good results with w3schools, but anyways I'll check those out.

Thanks

boogyman
01-11-2008, 07:43 PM
I had nothing specific in mind about what to do with them, just somehow prevent them from doing anything.
nothing as in do not process them or nothing as do not include them at all

if you want to keep the html tags, eg... some code is posted to you to review, you can review

htmlspecialchars($tring)
if you would like to just get rid of the tags all together you can review

strip_tags($string)
in either event I would check into removing excess whitespace before / after the input entered with

trim($tring)