Hi,
I have recently taken up PHP programming, and I got stuck on the
following.
<?
$p_body = (isset ($_POST['body' ]) && ($_POST['body'] != '')) ?
$_POST['body'] : 'Enter your text here';
$p_name = (isset ($_POST['name' ]) && ($_POST['name'] != '')) ?
$_POST['name'] : 'Enter name';
$p_mail = (isset ($_POST['mail' ]) && ($_POST['mail'] != '')) ?
$_POST['mail'] : 'Enter email';
$output = <<<CODEREH
<form method="POST" action="doform. php">
<p><input type="TEXT" name="name" value="$p_name" /></p>
<p><input type="TEXT" name="email" value="$p_mail" /></p>
<p><input type="TEXT" name="body" value="$p_body" /></p>
<p><input type="SUBMIT" value="Store it!" /></p>
</form>
CODEREH;
$invalid_body=a rray('','Enter your text here');
$invalid_name=a rray('','Enter name');
$invalid_mail=a rray('','Enter email');
if (validate($p_bo dy,$invalid_bod y) && validate($p_nam e,$invalid_name )
&& validate($p_mai l,$invalid_mail )) // fields not entered correctly
{
//process form data and provide link to continue (or enter another
set of data)
exit;
}
// data not entered correctly
echo "All fields must be entered!";
?>
If either field contains backslashes, they are duplicated when the
form reloads.
Each successive form submission \ becomes \\, \\\\, \\\\\\\\ etc etc
Why does this happen and how do I fix the variables to show the
original data each time?
I know I am a newbie, probably an easy one for this group. Can you
help me out though?
Semi
I have recently taken up PHP programming, and I got stuck on the
following.
<?
$p_body = (isset ($_POST['body' ]) && ($_POST['body'] != '')) ?
$_POST['body'] : 'Enter your text here';
$p_name = (isset ($_POST['name' ]) && ($_POST['name'] != '')) ?
$_POST['name'] : 'Enter name';
$p_mail = (isset ($_POST['mail' ]) && ($_POST['mail'] != '')) ?
$_POST['mail'] : 'Enter email';
$output = <<<CODEREH
<form method="POST" action="doform. php">
<p><input type="TEXT" name="name" value="$p_name" /></p>
<p><input type="TEXT" name="email" value="$p_mail" /></p>
<p><input type="TEXT" name="body" value="$p_body" /></p>
<p><input type="SUBMIT" value="Store it!" /></p>
</form>
CODEREH;
$invalid_body=a rray('','Enter your text here');
$invalid_name=a rray('','Enter name');
$invalid_mail=a rray('','Enter email');
if (validate($p_bo dy,$invalid_bod y) && validate($p_nam e,$invalid_name )
&& validate($p_mai l,$invalid_mail )) // fields not entered correctly
{
//process form data and provide link to continue (or enter another
set of data)
exit;
}
// data not entered correctly
echo "All fields must be entered!";
?>
If either field contains backslashes, they are duplicated when the
form reloads.
Each successive form submission \ becomes \\, \\\\, \\\\\\\\ etc etc
Why does this happen and how do I fix the variables to show the
original data each time?
I know I am a newbie, probably an easy one for this group. Can you
help me out though?
Semi
Comment