Can someone give me a pointer, please.
I am getting the following errors:
Notice: Undefined index: sender_name in c:\program files\apache
group\apache\htdocs\allinone_form.php on line 12
Notice: Undefined index: sender_email in c:\program files\apache
group\apache\htdocs\allinone_form.php on line 14
Notice: Undefined index: message in c:\program files\apache
group\apache\htdocs\allinone_form.php on line 16
Notice: Undefined index: op in c:\program files\apache
group\apache\htdocs\allinone_form.php on line 24
Here is my script:
<html>
<head>
<title>All-In-One Feedback Form</title>
</head>
<body>
<?
$form_block = "
<form method=\"POST\" ACTION=\"$_SERVER[PHP_SELF]\">
<p><strong>Your Name:<br>
<input type=\"text\" name=\"sender_name\" value=\"$_POST[sender_name]\"
size=30></p>
<p><strong>Your Email Address:<br>
<input type=\"text\" name=\"sender_email\" value=\"$_POST[sender_email]\"
size=30></p>
<p><strong>Message:</strong><br>
<textarea name=\"message\" cols=50 rows=5 wrap=virtual>$_POST[message]
</textarea></p>
<input name=\"op\" type=\"hidden\" value=\"ds\">
<p><input type=\"submit\" name=\"submit\" value\"Send This Form\"></p>
</form>";
$send = "yes";
if ($_POST["op"] !="ds") {
//they need to see the form
echo "$form_block";
}
else if ($_POST["op"] == "ds") {
if ($_POST["sender_name"] == ""){
$name_err = "<font color=red>Please enter your name!</font><br>";
$send = "no";}
else if ($_POST["sender_name"] != "")
{$name_err = "";}
if ($_POST["sender_email"] == "")
{$email_err = "<font color=red>Please enter your email
address!</font><br>";
$send = "no";}
else if ($_POST["sender_email"] != "")
{$email_err = "";}
if ($_POST["message"] == "")
{$message_err = "<font color=red>Please enter a message!</font><br>";
$send = "no";}
else if ($_POST["message"] != "")
{$message_err = "";}
if ($send != "no")
{
// it's ok to send!!
$to = "me@me.net";
$subject = "All-in-one Web Site Feedback";
$mailheaders = "From: My Web Site <> \n";
$mailheaders .= "Reply-To: $_POST[sender_email]\n\n";
$msg = "E-MAIL SEND FROM WWW SITE\n";
$msg .= "Sender's Name: $_POST[sender_name]\n";
$msg .= "Sender's E-mail: $_POST[sender_email]\n";
$msg .= "Message: $_POST[message]\n\n";
mail($to, $subject, $msg, $mailheaders);
echo "<p>Mail has been sent!</p>";
}
else if ($send == "no")
{
echo "$name_err";
echo "$email_err";
echo "$message_err";
echo "$form_block";
}
}
?>
</body>
</html> 5 2334
"Jerry Polyak" <jerrypolyak@NOSPAM_yahoo.com> wrote in message
news:FO********************@adelphia.com... Can someone give me a pointer, please.
I am getting the following errors:
Notice: Undefined index: sender_name in c:\program files\apache group\apache\htdocs\allinone_form.php on line 12
Notice: Undefined index: sender_email in c:\program files\apache group\apache\htdocs\allinone_form.php on line 14
Notice: Undefined index: message in c:\program files\apache group\apache\htdocs\allinone_form.php on line 16
Notice: Undefined index: op in c:\program files\apache group\apache\htdocs\allinone_form.php on line 24
Here is my script:
<snip>
It's fine, your errors are really warnings as a result of the first run of
the script not having anything in the $_POST variable to use as value=
attributes; presumably you've put them there because you want to repost the
same data if there's an error.
You could code round it, but it's easier to just put
error_reporting(E_ERROR);
at the top once you're satisfied that it works to your satisfaction. Or,
like me, even change the default in php.ini so that E_ERROR is usual and put
error_reporting(E_ALL); at the top of scripts that you're debugging.
HTH
Garp
"Garp" <ga***@no7.blueyonder.co.uk> wrote in message
news:TE*********************@news-text.cableinet.net... "Jerry Polyak" <jerrypolyak@NOSPAM_yahoo.com> wrote in message news:FO********************@adelphia.com... Can someone give me a pointer, please.
I am getting the following errors:
Notice: Undefined index: sender_name in c:\program files\apache group\apache\htdocs\allinone_form.php on line 12
Notice: Undefined index: sender_email in c:\program files\apache group\apache\htdocs\allinone_form.php on line 14
Notice: Undefined index: message in c:\program files\apache group\apache\htdocs\allinone_form.php on line 16
Notice: Undefined index: op in c:\program files\apache group\apache\htdocs\allinone_form.php on line 24
Here is my script: <snip>
It's fine, your errors are really warnings as a result of the first run of the script not having anything in the $_POST variable to use as value= attributes; presumably you've put them there because you want to repost
the same data if there's an error.
You could code round it, but it's easier to just put error_reporting(E_ERROR); at the top once you're satisfied that it works to your satisfaction. Or, like me, even change the default in php.ini so that E_ERROR is usual and
put error_reporting(E_ALL); at the top of scripts that you're debugging.
HTH Garp
Excellent, thank you.
I figured that is what the problem is (nothing to use for value), but had no
idea of the workaround. Kind of new to PHP.
Thanks again.
"Garp" <ga***@no7.blueyonder.co.uk> schrieb im Newsbeitrag
news:TE*********************@news-text.cableinet.net...
It's fine, your errors are really warnings as a result of the first run of the script not having anything in the $_POST variable to use as value= attributes; presumably you've put them there because you want to repost
the same data if there's an error.
You could code round it, but it's easier to just put error_reporting(E_ERROR); at the top once you're satisfied that it works to your satisfaction. Or, like me, even change the default in php.ini so that E_ERROR is usual and
put error_reporting(E_ALL); at the top of scripts that you're debugging.
Killing notices IMO is not debugging, but rather bugging! You can disable
the notice reporting _after_ debugging on going online, to prevent notices
from being displayed to the public, but they are essential for debugging.
For a quick solution, just fill the variables before you display the form:
if(isset($_POST['sender_name'])) $sender_name=$_POST['sender_name'];
else $sender_name="";
.... and so on. After that you just use $sender_name. Also note the 'quotes'
inside the ['brackets'].
A better solution would be to display the form at the end of the code flow.
So you can handle all your variable checking, then display a thank you
message if all is ok or display the form again with the messages and the
entries if it has to be resubmitted.
HTH
Markus
"Markus Ernst" <derernst@NO#SP#AMgmx.ch> wrote in message
news:40**********************@news.easynet.ch... "Garp" <ga***@no7.blueyonder.co.uk> schrieb im Newsbeitrag news:TE*********************@news-text.cableinet.net...
It's fine, your errors are really warnings as a result of the first run
of the script not having anything in the $_POST variable to use as value= attributes; presumably you've put them there because you want to repost the same data if there's an error.
You could code round it, but it's easier to just put error_reporting(E_ERROR); at the top once you're satisfied that it works to your satisfaction. Or, like me, even change the default in php.ini so that E_ERROR is usual and put error_reporting(E_ALL); at the top of scripts that you're debugging.
Killing notices IMO is not debugging, but rather bugging! You can disable the notice reporting _after_ debugging on going online, to prevent notices from being displayed to the public, but they are essential for debugging.
Isn't that what I said? I use E_ALL while debugging, then remove it and keep
warnings hidden while keeping actual errors visible? I was in a hurry, maybe
I phrased it badly. For a quick solution, just fill the variables before you display the form:
if(isset($_POST['sender_name'])) $sender_name=$_POST['sender_name']; else $sender_name="";
... and so on. After that you just use $sender_name. Also note the
'quotes' inside the ['brackets'].
A better solution would be to display the form at the end of the code
flow. So you can handle all your variable checking, then display a thank you message if all is ok or display the form again with the messages and the entries if it has to be resubmitted.
So like I said, you could code round it...
Garp
"Markus Ernst" <derernst@NO#SP#AMgmx.ch> wrote in message
news:40**********************@news.easynet.ch... "Garp" <ga***@no7.blueyonder.co.uk> schrieb im Newsbeitrag news:TE*********************@news-text.cableinet.net...
It's fine, your errors are really warnings as a result of the first run
of the script not having anything in the $_POST variable to use as value= attributes; presumably you've put them there because you want to repost the same data if there's an error.
You could code round it, but it's easier to just put error_reporting(E_ERROR); at the top once you're satisfied that it works to your satisfaction. Or, like me, even change the default in php.ini so that E_ERROR is usual and put error_reporting(E_ALL); at the top of scripts that you're debugging.
Killing notices IMO is not debugging, but rather bugging! You can disable the notice reporting _after_ debugging on going online, to prevent notices from being displayed to the public, but they are essential for debugging.
For a quick solution, just fill the variables before you display the form:
if(isset($_POST['sender_name'])) $sender_name=$_POST['sender_name']; else $sender_name="";
... and so on. After that you just use $sender_name. Also note the
'quotes' inside the ['brackets'].
A better solution would be to display the form at the end of the code
flow. So you can handle all your variable checking, then display a thank you message if all is ok or display the form again with the messages and the entries if it has to be resubmitted.
HTH Markus
Makes sense. As I said, I'm new to this. The form does what it has to, so
turning off debugging worked fine.
But I also see how filling the variables would work. Thanks for the tip. I
am sure I will use it in the future. For now this school assignment has
taken enough of my time.
Thanks to everyone for the help. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: mike |
last post by:
Hello,
After trying to validate this page for a couple of days now I was
wondering if someone might be able to help me out. Below is a list of
snippets where I am having the errors.
1. Line 334,...
|
by: John Flynn |
last post by:
hi all
i'm going to be quick i have an assignment due which i have no idea how to
do. i work full time so i dont have the time to learn it and its due date
has crept up on me ..
As follows:...
|
by: xunling |
last post by:
i have a question about answering ..... this topic is "need help"
what do i have to write at te topic line, !after i have klicked the
"answer message" button
ive tried many possibilities,...
|
by: sk |
last post by:
I have an applicaton in which I collect data for different parameters
for a set of devices. The data are entered into a single table, each
set of name, value pairs time-stamped and associated with...
|
by: Timothy Shih |
last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I
wrote a simple function which takes in 2 buffers (one a byte buffer, one a
char buffer) and copies the contents of the byte...
|
by: Cheryl Langdon |
last post by:
Hello everyone,
This is my first attempt at getting help in this manner. Please
forgive me if this is an inappropriate request.
I suddenly find myself in urgent need of instruction on how to...
|
by: pamelafluente |
last post by:
I am still working with no success on that client/server
problem. I need your help. I will submit simplified versions
of my problem so we can see clearly what is going on.
My model:
A client...
|
by: skumar434 |
last post by:
i need to store the data from a data base in to structure
.............the problem is like this ....suppose there is a data base
which stores the sequence no and item type etc ...but i need only...
|
by: U S Contractors Offering Service A Non-profit |
last post by:
Brilliant technology helping those most in need Inbox
Reply
U S Contractors Offering Service A Non-profit
show details
10:37 pm (1 hour ago)
Brilliant technology helping those most in need ...
|
by: mike |
last post by:
I help manage a large web site, one that has over
600 html pages... It's a reference site for ham radio
folks and as an example, one page indexes over
1.8 gb of on-line PDF documents.
The site...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |