473,402 Members | 2,072 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

need help

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>
Jul 17 '05 #1
5 2336

"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
Jul 17 '05 #2

"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.
Jul 17 '05 #3
"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
Jul 17 '05 #4

"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
Jul 17 '05 #5

"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.
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
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,...
5
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:...
0
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,...
9
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...
7
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...
15
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...
16
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...
8
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...
0
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 ...
20
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.