I am building a script that has a form so ppl can send some content. One of the fields of the form is for text. Also i am very new to php, so maybe my question is pretty easy to figure out.
Now the problem is in that field. I need that field to accept all kind of chars like slashes (/\) and other chars. When someone submits something php saves it in the database with more slashes then the original field content had.
I am using nl2br function to add br tags. The text field should act as a what you type is what the output should be....
Also if i use stripslashes() i get less of them then what was typed by the user.
Code:
Code: Select all
function adddataentry() {
global $prefix, $db, $modulename, $user, $allowusersubmit, $onlyregusers;
$mainindex = 1;
mainheader($mainindex);
if ($allowusersubmit == 1) {
if (is_user($user)) {
$isuser = 1;
} else {
$isuser = 0;
}
if ($isuser == 0 and $onlyregusers == 1) {
OpenTable();
echo ""._ONLYREGUSERS."";
CloseTable();
} elseif ($isuser == 1 and $onlyregusers == 1) {
include("includes/addform.php");
} else {
include("includes/addform.php");
}
} else {
OpenTable();
echo ""._POSTDISABLED."";
CloseTable();
}
}
function previewform($newcategory, $itemauthor, $itemwebsite, $itemtitle, $submitter, $email, $descrip, $content, $bypassq) {
global $prefix, $db, $modulename;
checktitle($itemtitle);
checkbad($content);
errors();
$mainindex = 1;
mainheader($mainindex);
$formattedcontent = nl2br($content);
OpenTable();
echo "<table border="0" width="100%">"
."<tr>"
."<td width="100%" valign="top">"
."<p align="center"><b>"._PREVIEWHEAD."</b></td>"
."</tr>"
."</table>";
CloseTable();
OpenTable();
echo "<table border="0" width="100%">"
."<tr>"
."<td width="100%">"
."<p align="center"> "._PREVIEWTITLE."</td>"
."</tr>"
."<tr>"
."<td width="100%"> <table border="2" bordercolor="#C0C0C0" width="100%">"
."<tr>"
."<td width="100%">"
."<p align="left">$formattedcontent</td>"
."</tr>"
."</table>"
."<p> </td>"
."</tr>"
."<tr>"
."<td width="100%">"
."<p align="center"> "._PREVIEWREQUEST."</td>"
."</tr>"
."</table>";
CloseTable();
include("modules/$modulename/includes/modifyform.php");
}
function postdata($newcategory, $itemauthor, $itemwebsite, $itemtitle, $submitter, $email, $descrip, $content, $bypassq) {
global $prefix, $db, $modulename, $mainprefix;
checktitle($itemtitle);
errors();
$content2= stripslashes($content);
$descrip2= stripslashes($descrip);
$submitter2= stripslashes($submitter);
$itemtitle2= stripslashes($itemtitle);
$itemauthor2= stripslashes($itemauthor);
$datea = date("Y-m-d H:i:s");
$db->sql_query("INSERT into musica_tabs_queue VALUES ('', '$newcategory', '$itemauthor2', '$itemwebsite', '$itemtitle2', '$descrip2', '$content2', '$submitter2', '$email')");
$posted = 0;
$result = $db->sql_query("select id from ".$prefix."_".$mainprefix."_queue");
$waiting = $db->sql_numrows($result);
include("header.php");
include("modules/$modulename/includes/js.php");
$mainindex = 1;
mainheader($mainindex);
if ($posted == 1) {
OpenTable();
echo ""._ADMINPOSTED."";
CloseTable();
} else {
OpenTable();
echo "<table border="0" width="100%">"
."<tr>"
."<td width="100%" align="center">"._ADDPOSTHEADER.".</td>"
."</tr>"
."<tr>"
."<td width="100%" align="center">"._ADDPOSTMESSAGE.".</td>"
."</tr>"
."<tr>"
."<td width="100%" align="center"> </td>"
."</tr>"
."<tr>"
."<td width="100%" align="center">"._ADDPOSTPART1." $waiting "._ADDPOSTPART2.".</td>"
."</tr>"
."</table>";
CloseTable();
}
}Thank you for any help!
feyd|use
Code: Select all
tags please.[/color]