Jump to content

[SOLVED] form help


dumdumsareyum

Recommended Posts

I'm very new to php and I'm having trouble getting values from a form. The form has 3 text fields, 4 checkboxes and 4 radio buttons, and then the script is supposed to simply display all the values in the $_POST array after submitted. The problem I'm having is that, no matter what order I put the elements of the form in, the first value submitted is not displayed (i.e. if i put the text fields first, the first text field value is not reported, if the checkboxes are first then the first checkbox will not have a value displayed. Thanks for any advice.

Link to comment
https://forums.phpfreaks.com/topic/53110-solved-form-help/
Share on other sites

Sure, don't laugh at the content too much, it was just for practice  :)

 

 

<html>

<head>

<title>Forms Practice</title

</head>

 

<body>

 

<form action = "processforms.php" method = "POST">

 

 

 

 

Please check all that apply: <br>

 

<INPUT TYPE = "checkbox" NAME = "Catlover"> I love cats. <br>

<INPUT TYPE = "checkbox" NAME = "Doglover" > I love dogs. <br>

<INPUT TYPE = "checkbox" NAME = "Cat" > I am a cat. <br>

<INPUT TYPE = "checkbox" NAME = "Dog" > I am a dog. <br>

Last Name:

<INPUT TYPE = "TEXT" NAME = "LastName"  SIZE = "25" MAXLENGTH = "40">

<br>

First Name:

        <INPUT TYPE = "TEXT" NAME = "FirstName" SIZE = "25" MAXLENGTH = "40">

<br>

Password:

<INPUT TYPE = "PASSWORD" NAME = "Password" SIZE = "25" MAXLENGTH = "40">

 

 

<p>

Please select your favorite activity: <br>

<INPUT TYPE = "Radio" NAME = "favorite" Value = "hairball"> Cough up hairballs <br>

<INPUT TYPE = "Radio" NAME = "favorite" Value = "dogwalk"> Take my dog for walks <br>

<INPUT TYPE = "Radio" NAME = "favorite" Value = "catwalk" > Take my cat for walks <br>

<INPUT TYPE = "Radio" NAME = "favorite" Value = "poop"> Eat my own poop <br>

</p>

 

<INPUT TYPE = "submit" NAME = "submit form" VALUE = "Submit" >

<INPUT TYPE = "reset" NAME = "reset form" VALUE = "Reset"> <br>

</form>

 

</body>

Link to comment
https://forums.phpfreaks.com/topic/53110-solved-form-help/#findComment-262372
Share on other sites

Seams OK to me

 

heres my test built from yours

<?php
   foreach ($_POST as $field => $value)
   {
    echo "$field = $value<br />";
   }

?>

<html>
<head>
<title>Forms Practice</title
</head>

<body>

<form method = "POST">
  

Please check all that apply:


<INPUT TYPE = "checkbox" NAME = "Catlover"> I love cats.

<INPUT TYPE = "checkbox" NAME = "Doglover" > I love dogs.

<INPUT TYPE = "checkbox" NAME = "Cat" > I am a cat.

<INPUT TYPE = "checkbox" NAME = "Dog" > I am a dog.

Last Name:
   <INPUT TYPE = "TEXT" NAME = "LastName"  SIZE = "25" MAXLENGTH = "40">
   

   First Name:
        <INPUT TYPE = "TEXT" NAME = "FirstName" SIZE = "25" MAXLENGTH = "40">
   

   Password:
   <INPUT TYPE = "PASSWORD" NAME = "Password" SIZE = "25" MAXLENGTH = "40">
   

<p>
Please select your favorite activity:

<INPUT TYPE = "Radio" NAME = "favorite" Value = "hairball"> Cough up hairballs

<INPUT TYPE = "Radio" NAME = "favorite" Value = "dogwalk"> Take my dog for walks

<INPUT TYPE = "Radio" NAME = "favorite" Value = "catwalk" > Take my cat for walks

<INPUT TYPE = "Radio" NAME = "favorite" Value = "poop"> Eat my own poop

</p>

<INPUT TYPE = "submit" NAME = "submit form" VALUE = "Submit" >
<INPUT TYPE = "reset" NAME = "reset form" VALUE = "Reset">

</form>

</body>

Link to comment
https://forums.phpfreaks.com/topic/53110-solved-form-help/#findComment-262380
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.