Jump to content

Beginner Form Problem


Bepo

Recommended Posts

Hey, I'm very new to PHP and I'm trying to create a form that posts data to a PHP document. Here's what I have so far:

 

form.html:

 

<form action="phpdoc.php" method="post"> 
<input type="checkbox" name="fun" value="yes" />Fun
<input type="checkbox" name="ent" value="yes" />Entertaining
<input type="checkbox" name="inf" value="yes" />Informative <br>
<input type="submit" name="formSubmit" value="Submit" />
</form>

 

phpdoc.php:

 

<?php 
 
if(isset($_POST['fun']) && 
   $_POST['fun'] == 'yes') 
{
    print "Try fdajkfda.";
}
else
{
    print "You aren't fun.";
}    
 
?>
 
The objective is to create a form with checkboxes, and so far, if you select the "fun" checkbox and submit the form, it will send the data to the phpdoc.php and the form will then print something depending on your selection. The problem is, the form isn't printing anything at all. This is a really amateur problem so I thank you for whatever help you can give  :happy-04:
Link to comment
https://forums.phpfreaks.com/topic/278487-beginner-form-problem/
Share on other sites

 

 

Hey, I'm very new to PHP and I'm trying to create a form that posts data to a PHP document. Here's what I have so far:

 

form.html:

 

<form action="phpdoc.php" method="post"> 
<input type="checkbox" name="fun" value="yes" />Fun
<input type="checkbox" name="ent" value="yes" />Entertaining
<input type="checkbox" name="inf" value="yes" />Informative <br>
<input type="submit" name="formSubmit" value="Submit" />
</form>

 

phpdoc.php:

 

<?php 
 
if(isset($_POST['fun']) && 
   $_POST['fun'] == 'yes') 
{
    print "Try fdajkfda.";
}
else
{
    print "You aren't fun.";
}    
 
?>
 
The objective is to create a form with checkboxes, and so far, if you select the "fun" checkbox and submit the form, it will send the data to the phpdoc.php and the form will then print something depending on your selection. The problem is, the form isn't printing anything at all. This is a really amateur problem so I thank you for whatever help you can give  :happy-04:

 

You can do print_r($_REQUEST);  at the top of phpdoc.php to see what kind of values are actually being posted. If you do that you should be able to see right away why this isn't working.

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.