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
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.

Edited by taquitosensei
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.