954,576 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

$_POST Undefined index

hello~
i just join in this discussion ....er i am Chinese,so my English is poor
i search this problem in Google,but i can't find some useful information
some people said PHP version cause this problem...
i use PHP 5.3.3 but i saw PHP 5.2.1 books

<html>
<title>
test
</title>
<body>
<div align="center">注册表单
<form id="form1" name="form1" method="post" action="1.php">
用户:<input type="text" name=:"username" id="username" />
密码:<input type="text" name=:"pass" id="pass" />
邮件:<input type="text" name=:"email" id="email" />
<input type="submit" name=:"button" id="button" value="提交" />
</form>
</div>
</body>
</html>
<?php
echo "注册的用户名: ".$_POST["username"]."";
echo "注册的密码: ".$_POST["pass"]."";
echo "注册的邮件: ".$_POST["email"]."";
echo "表单按钮: ".$_POST["button"]."";
?>


error:
Notice: Undefined index: in D:\Apache2.2\htdocs\1.php on line 7
注册的用户名:

Notice: Undefined index: in D:\Apache2.2\htdocs\1.php on line 8
注册的密码:

Notice: Undefined index: in D:\Apache2.2\htdocs\1.php on line 9
注册的邮件:

Notice: Undefined index: in D:\Apache2.2\htdocs\1.php on line 10
表单按钮:

thans your support:)

aiioef
Newbie Poster
5 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

why are there ":" in every input-element?

<html>
<title>
test
</title>
<body>
<div align="center">????
<form id="form1" name="form1" method="post" action="1.php">
??:<input type="text" name="username" id="username" />
??:<input type="text" name="pass" id="pass" />
??:<input type="text" name="email" id="email" />
<input type="submit" name="button" id="button" value="??" />
</form>
</div>
</body>
</html>


and the 1.php:

<?php if(isset($_POST['button'])) {
echo "??????: ".$_POST["username"]."";
echo "?????: ".$_POST["pass"]."";
echo "?????: ".$_POST["email"]."";
echo "????: ".$_POST["button"]."";
}
?>
Agarsia
Junior Poster
114 posts since Feb 2011
Reputation Points: 10
Solved Threads: 25
 

What are you asking?

public-image
Junior Poster in Training
76 posts since Oct 2010
Reputation Points: 10
Solved Threads: 11
 

error:

Notice: Undefined index: in D:\Apache2.2\htdocs\1.php on line 7
注册的用户名:

Notice: Undefined index: in D:\Apache2.2\htdocs\1.php on line 8
注册的密码:

Notice: Undefined index: in D:\Apache2.2\htdocs\1.php on line 9
注册的邮件:

Notice: Undefined index: in D:\Apache2.2\htdocs\1.php on line 10
表单按钮:

aiioef
Newbie Poster
5 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

I tested the solution i posted above and it worked...

Agarsia
Junior Poster
114 posts since Feb 2011
Reputation Points: 10
Solved Threads: 25
 

why are there ":" in every input-element?

<html>
<title>
test
</title>
<body>
<div align="center">????
<form id="form1" name="form1" method="post" action="1.php">
??:<input type="text" name="username" id="username" />
??:<input type="text" name="pass" id="pass" />
??:<input type="text" name="email" id="email" />
<input type="submit" name="button" id="button" value="??" />
</form>
</div>
</body>
</html>

and the 1.php:

<?php if(isset($_POST['button'])) {
echo "??????: ".$_POST["username"]."";
echo "?????: ".$_POST["pass"]."";
echo "?????: ".$_POST["email"]."";
echo "????: ".$_POST["button"]."";
}
?>


just for a good look.....Does not work

aiioef
Newbie Poster
5 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 
I tested the solution i posted above and it worked...


= =....i dont know.. its doesn't work in my computer

aiioef
Newbie Poster
5 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 
What are you asking?

error:
Notice: Undefined index: in D:\Apache2.2\htdocs\1.php on line 7
注册的用户名:

Notice: Undefined index: in D:\Apache2.2\htdocs\1.php on line 8
注册的密码:

Notice: Undefined index: in D:\Apache2.2\htdocs\1.php on line 9
注册的邮件:

Notice: Undefined index: in D:\Apache2.2\htdocs\1.php on line 10
表单按钮:

aiioef
Newbie Poster
5 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

Yes in the PHP Manual you will find everywhere

This feature has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged.

in functions for global Variables like $_GET, $_POST, $_SERVER

But I don't know any solutions for this problem, sorry

Agarsia
Junior Poster
114 posts since Feb 2011
Reputation Points: 10
Solved Threads: 25
 



Please Pay P80.

<?php

//CONDITIONAL STATEMENTS - PROBLEM SOLVING
if ($_POST['amount'] <> null )
{
if ($_POST['amount'] > 80)
{
$change = $_POST['amount'] - 80;
echo "You're change is :". $change." ";
}
else if ($_POST['amount'] < 80)
{
$change = ($_POST['amount'] - 80) * -1;
echo "Not enough. Please pay additional :". $change." ";
}
else
{
echo "Thank you for giving exact amount.";
}
}
?>

KENLIE
Newbie Poster
1 post since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

Hi aiioef, Its not a big problem , Try this, <?php error_reporting(E_ALL ^ E_NOTICE); ?> include this code on every top of the php file. That's all

mohamedasif18
Junior Poster in Training
61 posts since Nov 2011
Reputation Points: 10
Solved Threads: 5
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: