I want to input form data, display it for the user to edit, and then write it to the db. When I display for edit, I pass the data via hidden fields. I can't get the right combination of addslashes and stripslashes.
I need the slashes in to pass the data, but i don't want the slashes to show to the user.
Does anyone have the right combination to do this?
<?php
$quotes = get_magic_quotes_runtime();
$q2 = get_magic_quotes_gpc();
$status .='magic quotes runtime - '.$quotes.', magic quotes gpc - '.$q2.'<br>'; //0,1 - & I can't change them.
if (isset($submitProduct)) {
$status .='<b>submit for error checking section.</b><br>';
foreach ($_POST as $key => $value) {
$value = stripslashes($value);
$status .='key -> '.$key.', value -> '.$value.' <br>';
}
$status .='<FORM ACTION= ' . ($PHP_SELF) . ' METHOD=POST>
<input type=\'hidden\' name=\'descr\' value=\''.$descr.'\'>
<p>
To edit: <input type=\'submit\' name=\'displayform\' value=\'edit Product\'>
<p>To Save: <input type=\'submit\' name=\'write\' value=\'write Product\'></form>
';
} //isset submitProduct
if (isset($write)) {
$status .='<b>save data section</b><br>';
foreach ($_POST as $key => $value) {
$status .='key -> '.$key.', value -> '.$value.' <br>';
}
} // isset write
if (isset($displayform)) {
foreach ($_POST as $key => $value) {
$status .='key -> '.$key.', value -> '.$value.' <br>';
}
$descr = stripslashes($descr);
$status .= '
<FORM ACTION= ' . ($PHP_SELF) . ' METHOD=POST>
<textarea name=\'descr\' cols=\'40\' rows=\'3\' wrap=\'soft\'>'.$descr.'</textarea>
<p><input type=\'submit\' name=\'submitProduct\' value=\'Add Product\'></form>
';
} // isset displayform
$status .= '<p><a href=\'' . ($PHP_SELF) . '?displayform=1\'>display the form</a>';
// display sections
echo $status;
?>