opicoder Posted October 9, 2013 Share Posted October 9, 2013 Code: Nimesi: <?php echo $_POST['fname']; ?> Display when im not set the name: Notice: Undefined index: fname in C:\xampp\htdocs\index.php on line 24 Display when im set the name: Name: name how i can set the first name to "Quest"? Quote Link to comment Share on other sites More sharing options...
Love2c0de Posted October 9, 2013 Share Posted October 9, 2013 (edited) Good afternoon, You first want to check that the form has been submitted and that the $_POST superglobal actually contains a value. You should do this: <?php if(isset($_POST['fname'])) { //the $_POST superglobal holds value(s)! } else { //we got nothing. } ?> That will eliminate your Undefined Index problem. Now, what are you typing in the fname field in the form? It should display the value that you entered. Kind regards, L2c. Edited October 9, 2013 by Love2c0de Quote Link to comment Share on other sites More sharing options...
davidannis Posted October 9, 2013 Share Posted October 9, 2013 You should be getting the name from a form with an input field. You can default the value to Quest <form method="POST" action="myscript.php"> <input name="fname" type="text" value="Quest"> <input type="submit> </form> If you don't want the user to be able to change the value easily use type="hidden" instead of text. If you don't want the user to control the value then don't put it in the $_POST array. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.