<?php
function printForm($strMessage){
echo "<strong>" .$strMessage."</strong>";
echo "<form method=\"post\" action=\"" .$_SERVER['PHP_SELF']. "\" name=\"form\">\n<br>";
echo "Your Name: <input type=\"text\" Name=\"yname\" value=\"" .trim($_POST['yname'])."\"><br>";
echo "Your Email: <input type=\"text\" Name=\"yemail\" value=\"" .trim($_POST['yemail'])."\"><br>";
echo "Username: <input type=\"text\" Name=\"yusername\" value=\"" .trim($_POST['yusername'])."\"><br>";
echo "Password: <input type=\"password\" Name=\"pword\" value=\"" .trim($_POST['pword'])."\"><br>";
echo "Confirm Password: <input type=\"password\" Name=\"cpword\" value=\"" .trim($_POST['cpword'])."\"><br>";
echo "Comments: <textarea name=\"comments\" rows=\"5\" cols=\"20\"></textarea><br>";
echo "<input type=\"submit\" value=\"send\" Name=\"submit\"/>\n<br>";
echo "</form>\n";
}
?>
<html>
<head>
<title>Self Submitting Sticky Form</title>
<style>body {
background-color:red;
}
</style>
</head>
<body>
<?php
if(isset($_POST['submit'])){
$yourname=trim($_POST['yname']);
$youremail=trim($_POST['yemail']);
$yourusername=trim($_POST['yusername']);
$yourpassword=trim($_POST['pword']);
$yourcpassword=trim($_POST['cpword']);
if ($yourname==''){
$strMessage='Please enter your name.';
printForm($strMessage);
}
elseif ($youremail==''){
$strMessage='Please enter your email.';
printForm($strMessage);
}
elseif ($yourusername==''){
$strMessage='Please enter your username.';
printForm($strMessage);
}
elseif ($yourpassword==''){
$strMessage='Please enter your password.';
printForm($strMessage);
}
elseif ($yourcpassword==''){
$strMessage='Please confirm your password.';
printForm($strMessage);
}
elseif ($yourcpassword != $yourpassword){
$strMessage='passwords must match.';
printForm($strMessage);
}
elseif(strlen($yourpassword) <= 3 ){
$strMessage='passwords must be at least 4 characters.';
printForm($strMessage);
}
else{
$strMessage='Thank you. your information was sent.';
echo $strMessage;
}
}
else{
$strMessage='Please enter all fields below:';
printForm($strMessage);
}
?>
</body>
</html>
why are comments not being saved in form
Page 1 of 13 Replies - 100 Views - Last Post: 22 February 2013 - 07:45 PM
#1
why are comments not being saved in form
Posted 22 February 2013 - 03:03 AM
Here is my code I can not figure out why my comments are not being saved if the user would enter something wrong and be redirected all fields should be remembered but comments are not for some reason please submit my error and the correct way so I may fix it thanks.
Replies To: why are comments not being saved in form
#2
Re: why are comments not being saved in form
Posted 22 February 2013 - 04:03 AM
echo "Comments: <textarea name=\"comments\" rows=\"5\" cols=\"20\"></textarea><br>";
It is because you are using <textarea> as an empty tag, by not providing any text in it.
regards,
Raghav
#3
Re: why are comments not being saved in form
Posted 22 February 2013 - 04:11 AM
Try this and see if it helps.
regards,
Raghav
echo "Comments: <textarea name=\"comments\" rows=\"5\" cols=\"20\" >".trim($_POST['comments'])."</textarea><br>";
regards,
Raghav
#4
Re: why are comments not being saved in form
Posted 22 February 2013 - 07:45 PM
thanks so much it works perfect now its just little things like that, that sometimes you look at them so much you can be blinded to a error like mine lol I really appreciate the help.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote



|