Whats Wrong !!
Posted by: vishruth (---.61.166.122.airtelbroadband.in)
Date: February 19, 2010 10:35PM

Hi,

I am trying to run the following simple code:

HTML Code:
-----------

<html>
<head>
<title> </title>
</head>

<body>

<form action="welcome.php" method=”post”>

Enter Customer Name <input type="text" name="cusname" />
<br>
<br>
Enter Particulars Name <input type="text" name="parname" />
<br>
<br>
Enter Rate <input type="text "name="parrate" />
<br>
<br>

<input type="submit" value="Enter"> <br>

</form>

</body>
</html>

===============================================

Welcome.php Code:
------------------

<?php

echo $_POST["cusname"];
echo $_POST["parname"];
echo $_POST["parrate"];

?>

===============================================

But getting the error which says:

"NOTICE: Undefined index cusname in c://wamp/www/web/welcome.php on line 3"
and similarly for line 4 and 5.

Please help me on this.

Thanks in advance,
Vishruth

Options: ReplyQuote
Re: Whats Wrong !!
Posted by: stevenmartin99 (---.b-ras2.blp.dublin.eircom.net)
Date: February 19, 2010 10:40PM

u didnt define the variables

u need

$variable = $_POST['variable'];

echo $variable;

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: Whats Wrong !!
Posted by: c2dan (---.15-1.cable.virginmedia.com)
Date: February 20, 2010 11:52AM

Make sure you're filling in the form first and submitting the form. If you're just going directly to welcome.php without going to the form first your _POST variables will not exist.

Make sure you're going to [localhost] too when running your php scripts.

Options: ReplyQuote
Re: Whats Wrong !!
Posted by: vishruth (---.61.166.122.airtelbroadband.in)
Date: February 22, 2010 05:17PM

Thanks for your response,

I have filled in the form before going to welcome.php and I have done all work thru "Loclhost".

Few internet sites suggest to Disalbe some error reporting feature in PHP.ini

"error_reporting(E_ALL ^ E_NOTICE);" -- But when i did that I just got a blank page.

Kindly help me on this.

Thanks Much,
Vishruth

Options: ReplyQuote
Re: Whats Wrong !!
Posted by: Dicky (---.wltonh.dsl.dynamic.tds.net)
Date: February 22, 2010 06:54PM

The problem is that you have smart quotes around post instead of regular quotes.

It should be

<form action="welcome.php" method="post">

Options: ReplyQuote
Re: Whats Wrong !!
Posted by: c2dan (---.15-1.cable.virginmedia.com)
Date: February 22, 2010 06:56PM

I just noticed something in your code. You're using the wrong type of quotes on this line
<form action="welcome.php" method=”post”>

” should be " (increase text size to see the difference <-- Press Ctrl and + keys).

vishruth Wrote:
-------------------------------------------------------
> Few internet sites suggest to Disalbe some error
> reporting feature in PHP.ini
>
> "error_reporting(E_ALL ^ E_NOTICE);" -- But when
> i did that I just got a blank page.

No you shouldn't do that that. When developing code you should leave error_reporting set to E_ALL

Options: ReplyQuote
Re: Whats Wrong !!
Posted by: t0mmerz (---.direcpc.com)
Date: February 23, 2010 12:10AM

To not show the errors before you fill out the form, do:
<?php
if(array_key_exists("cusname", $_POST) && array_key_exists("parname", $_POST) && array_key_exists("parrate", $_POST))
{
// echo your variables.
}
else
{
// show the form
}
?>

Sincerely, AciD
[elite-area.com]
[imperialbb.com]

Options: ReplyQuote


Sorry, only registered users may post in this forum.