Re-populating form field

JV17

Im trying to re-populate a field in my form but when I go inside my website it show some weird warning or code inside this field which is:

Notice: Undefined index: firstname in /home/int322_133a31/apache/htdocs/lab5/forms-part3.php on line 24

This is some part of my code for the form

<body>
<form method="post" action="forms-part3.php">
<table>
    <tr>
        <th colspan="2">FSOSS Registration</th>
    </tr>
    <tr>
        <td><br /></td>
    </tr>
    <tr>
        <td class="right text">Title:</td>
        <td><input type="radio" name="sex" value="male">Mr.</td></tr>
    <tr><td></td><td><input type="radio" name="sex" value="female">Mrs.</td></tr>
    <tr><td></td><td><input type="radio" name="sex" value="female">Ms.</td>
    </tr>                
    <tr>
        <td class="right text">First Name:</td>
        <td><input type="text" name="firstname" size="28" value="<?php echo     $_POST['firstname'];?>"></td>
    </tr>
</table>

And this is for getting what the user input

<?php
if ($_POST){
$sex=$_POST['sex'];
$firstName=$_POST['firstname'];
$lastName=$_POST['lastname'];
$organization=$_POST['organization'];
$email=$_POST['emailaddress'];
$phone=$_POST['phonenumber'];
$selection=$_POST['selection'];
?>
vaibhavmande

The warning might be showing up first time when you visit the page since the $_POST is not set yet.

Change,

<td><input type="text" name="firstname" size="28" value="<?php echo $_POST['firstname'];?>"></td>

To,

<td><input type="text" name="firstname" size="28" value="<?php if(isset($_POST['firstname'])){echo $_POST['firstname'];} ?>"></td>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Re-populating form field

From Dev

Hidden attribute not populating field in form for Rails 3.2

From Dev

Simple form date_field not populating for edit

From Dev

Simple form date_field not populating for edit

From Dev

Form Validation & Re-Populating Field Values After Redirect Error; Validation Works, But Values Doesn't (CodeIgniter 3)

From Dev

Re-populating radio buttons and selection option in a form

From Dev

ZF2 Doctrine2 populating a form with a date field

From Dev

Issue with dynamically populating dropdownlist for a field in django custom user registration form

From Dev

Auto Populating the first instance of a nested form field in Ruby on Rails

From Dev

populating a dynamic form with javascript

From Dev

Symfony form handleRequest not populating

From Dev

populating form with mysql data

From Dev

populating a dynamic form with javascript

From Dev

removing and re-populating boostrapTable

From Dev

Populating input field with JSON data

From Dev

Populating text field in prototype cell

From Dev

Populating a dropdown field using php

From Dev

Cocoon populating form in reverse order

From Dev

Populating a calculated value into another form

From Dev

Ajax dont works populating a form

From Dev

In AngularJS, how to force the re-validation of a field in a form when another value in the same form is changed?

From Dev

Update GridView/ListView without re-populating

From Dev

Data not populating in UIPickerView when field is tapped

From Dev

TFS work item field "Integrated in build" not populating

From Dev

Populating select input field with value from mysql

From Dev

Populating the select input field with mysql data

From Dev

jquery mobile date field default value not populating

From Dev

Populating Input Field With CFC JSON Results

From Dev

AngularJS Populating input field with directive but not captured in $scope

Related Related

  1. 1

    Re-populating form field

  2. 2

    Hidden attribute not populating field in form for Rails 3.2

  3. 3

    Simple form date_field not populating for edit

  4. 4

    Simple form date_field not populating for edit

  5. 5

    Form Validation & Re-Populating Field Values After Redirect Error; Validation Works, But Values Doesn't (CodeIgniter 3)

  6. 6

    Re-populating radio buttons and selection option in a form

  7. 7

    ZF2 Doctrine2 populating a form with a date field

  8. 8

    Issue with dynamically populating dropdownlist for a field in django custom user registration form

  9. 9

    Auto Populating the first instance of a nested form field in Ruby on Rails

  10. 10

    populating a dynamic form with javascript

  11. 11

    Symfony form handleRequest not populating

  12. 12

    populating form with mysql data

  13. 13

    populating a dynamic form with javascript

  14. 14

    removing and re-populating boostrapTable

  15. 15

    Populating input field with JSON data

  16. 16

    Populating text field in prototype cell

  17. 17

    Populating a dropdown field using php

  18. 18

    Cocoon populating form in reverse order

  19. 19

    Populating a calculated value into another form

  20. 20

    Ajax dont works populating a form

  21. 21

    In AngularJS, how to force the re-validation of a field in a form when another value in the same form is changed?

  22. 22

    Update GridView/ListView without re-populating

  23. 23

    Data not populating in UIPickerView when field is tapped

  24. 24

    TFS work item field "Integrated in build" not populating

  25. 25

    Populating select input field with value from mysql

  26. 26

    Populating the select input field with mysql data

  27. 27

    jquery mobile date field default value not populating

  28. 28

    Populating Input Field With CFC JSON Results

  29. 29

    AngularJS Populating input field with directive but not captured in $scope

HotTag

Archive