Page 1 of 1
Creating a post page
Posted: Wed Oct 12, 2005 10:02 pm
by Sequalit
Im having difficulties creating a page like like the post new topic page...
where i can have the textarea also save the linebreaks (or enter button) in my sql database and then when i display the data on my front page it puts all the code nice and neat, like viewing a post...
Any help or pointers would be much apprecieated.
-SeQ
Posted: Wed Oct 12, 2005 10:10 pm
by feyd
when displaying, you run the text through
nl2br(). If you're wanting to use bbcode like tags, you'll need to dig around for some code snippets (they're all over the place) that can perform the various functions you wish to have. These are usually preparsed during storage into the database.
Posted: Wed Oct 12, 2005 11:47 pm
by Sequalit
That nl2br() thing works great... now im having trouble getting it implemented with my ereg();.. ive done some searching but cant seem to get the right combination... ive tried adding the <br> tags to the ereg() but it never see's it.. or somethings up im not quite sure.
Code: Select all
$ftype = strip_tags($ftype);
$fdisc = strip_tags($fdisc);
$fdisc = nl2br($fdisc);
if(!ereg("^[A-Z a-z 0-9 ( ) , ! ? . - :]+$", $ftype)){
echo "The type of event is incorrect, make sure you have no wierd symbols in the name.<br>";
redirect();
die();
}elseif(!ereg("^[A-Z a-z 0-9 ( ) , ! ? . - : ]+$", $fdisc)){
echo "The discription of event is incorrect, make sure you have no wierd symbols in the name.<br>";
redirect();
die();
}
Posted: Thu Oct 13, 2005 12:42 am
by Sequalit
Alright, I got it with trial and error! w00t...
It doesnt look like probably the best way to do it... but it works LOL *grin* im happy.
Code: Select all
$ftype = strip_tags($ftype);
$fdisc = strip_tags($fdisc);
$fdisc = nl2br($fdisc);
if(!ereg("^[A-Z a-z 0-9 ( ) , ! ? . - :]+$", $ftype)){
echo "The type of event is incorrect, make sure you have no wierd symbols in the name.<br>";
redirect();
die();
}elseif(!ereg("^[A-Z a-z 0-9 ( ) , ! ? . - :]+$", $fdisc)){
if(ereg("(\<br \/\>)",$fdisc)){
}else{
echo "The discription of event is incorrect, make sure you have no wierd symbols in the name.<br>";
redirect();
die();
}
}
Posted: Thu Oct 13, 2005 1:42 am
by feyd
the ereg functions are very slow compared to the preg functions, fyi.
Posted: Thu Oct 13, 2005 1:46 am
by Sequalit
so would replaces ereg() with preg_match_all() be more effecient?
Posted: Thu Oct 13, 2005 1:55 am
by Sequalit
Ok I altered my code to this, seems to work fine.
Code: Select all
$ftype = strip_tags($ftype);
$fdisc = strip_tags($fdisc);
$fdisc = nl2br($fdisc);
if(!preg_match("/^[A-Z a-z 0-9 ( ) , ! ? . - :]+$/", $ftype)){
echo "The type of event is incorrect, make sure you have no wierd symbols in the name.<br>";
redirect();
die();
}elseif(!preg_match("/^[A-Z a-z 0-9 ( ) , ! ? . - :]+$/", $fdisc)){
if(preg_match("/(\<br \/\>)/",$fdisc,$out)){
}else{
echo "The discription of event is incorrect, make sure you have no wierd symbols in the name.<br>";
redirect();
die();
}
}