i have just created a form to test string function.. i created this func.html <form method="post" action="func.php" /> <p> <textarea name="text" cols="50" rows="5" wrap="virtual"></textarea> <br /> <input type="radio" name="func" value="md5" /> MD5 <br /> <input type="radio" name="func" value="strlen" /> String Length <br /> <input type="radio" name="func" value="strrev" /> String Reverse<br /> <input type ="radio" name="func" value="strtoupper" /> String to Upper<br /> <input type="radio" name="func" value="strtolower" /> String to lower<br /> <input type="radio" name="func" value="ucwords" /> First Word to Uper Case<br /> <input type="submit" name="submit" value="Go" /> HTML: And then created php file "func.php" <? if (($_POST[text] == "") || $_POST[func] == "")) { { header("Location: func.html"); exit; } $result = $_POST[func] ($_POST[text]); ?> <b>The Result is <b><? echo $result ?> Code (markup): Every thing is working fine when i remove this function if (($_POST[text] == "") || $_POST[func] == "")) { { header("Location: func.html"); exit; } Code (markup): i use this function because if user donot put text or select radio button then header function again bring user to main page.. Help me out why header function is not working even on other scripts i made.. THANKS
Where in the code did you put the function? It should be on the beginning, before the <html> tag. Because I think you can't send another header, if the headers are already set.
means i have to use like this? <? if (($_POST[func] == "") && ($_POST[text] == "")) { header("Location: func.html"); exit; } $result = $_POST[func] ($_POST[text]); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <b>The Result is <b><? echo $result ?> </body> </html> HTML:
Hey SHALL.. You are totally right.. i use it before html tags or delete all html tags and now it is working perfectly.. Thanks to you sir..