SO here is the thing i have one file called test.php which has this code in it <form action="test2.php" method="post"> <input type="text" name="test"> <input type="submit"> </form> then it submits info to test2 which has this code in it <?php echo $_POST["test"]; ?> Now can you please guys tell me what the hell in the world am i doing wrong that its is giving me the error Notice: Undefined index: test in /home/sendmail/public_html/test2.php on line 2 Please help, - Avo
It means the variable you are trying to use doesn't exist. Wrap the $_POST['text'] part in a if-statement. <form action="test2.php" method="post"> <input type="text" name="test"> <input type="submit"> </form> <?php if (isset($_POST["test"])) { echo $_POST["test"]; } ?> PHP: or <form action="test2.php" method="post"> <input type="text" name="test"> <input type="submit" name="submit"> </form> <?php if (isset($_POST["submit"])) { echo $_POST["test"]; } ?> PHP: - ads2help
Notice is not an error. you can just ignore it, default php setting disable notice reporting. to disable notice add this command at top of the script (usually index.php or config) error_reporting(E_ALL ^ E_NOTICE);
Hello, Well try to use this script and see what happens. <form action="test2.php" method="post"> <input type="text" name="test" id="test"> <input type="submit" name="rePost" id="rePost" value="Submit" /> <input type="hidden" name="rePost" id="rePost" /> </form> <?php error_reporting(0); if (isset($_POST["rePost"])) { echo $_POST["test"]; }?> Code (markup):