Jump to content

error need help,checkbox POST form cant work!


wolvesbane

Recommended Posts

Hey there, I've been trying to find the cause of the problem but couldn't. needed help from experts out there. the code supposed to echo it's submitted value on the same form when the checkbox is changed.

 

here's the code:

<!DOCTYPE html>
 
<?php
$office = $_POST["office"];
echo $office;
?>
<html>
    <body>
        <?php
        if (isset($office)) {
            echo "ON<br>";
         
        } else {
            echo 'OFF<br>';
         
        }
        ?> 
 
        <form name="checkbox" method="POST" action="interfaceButton.php" enctype="multipart/form-data">
<?php
if(isset($office)){
echo "asdfaf";
           echo "<input type='checkbox' name='office' value='on' checked onclick='this.form.submit();'";>
}
else{
 
           echo '<input type="checkbox" name="office" value=""  onClick="submit();"';}
?>
        </form>
    </body>
</html>
 
Was going to make use this concept and replace the input like a switch button for an web automation project. but im stuck here.
 
Link to comment
Share on other sites

Hey there, I've been trying to find the cause of the problem but couldn't. needed help from experts out there. the code supposed to echo it's submitted value on the same form when the checkbox is changed.

 

here's the code:

 

<!DOCTYPE html>

<?php
$office = $_POST["office"];
echo $office;
?>
<html>
    <body>
        <?php
        if (isset($office)) {
            echo "ON<br>";
         
        } else {
            echo 'OFF<br>';
         
        }
        ?> 

        <form name="checkbox" method="POST" action="interfaceButton.php" enctype="multipart/form-data">
		<?php
		if(isset($office)){
		echo "asdfaf";
           echo "<input type='checkbox' name='office' value='on' checked onclick='this.form.submit();'";>
			}
			else{
			
           echo '<input type="checkbox" name="office" value=""  onClick="submit();"';}
?>
        </form>
    </body>
</html>

Was going to make use this concept and replace the input like a switch button for an web automation project. but im stuck here.
 
output given when code was tried was:
 
"; } else { echo 'OFF
'; } ?> } else{ echo '<input type="checkbox" data-cke-saved-name="office" name="office" value="" ';}="" ?="">

 

 

 

Link to comment
Share on other sites

 

output given when code was tried was:

 
"; } else { echo 'OFF

'; } ?> } else{ echo '<input type="checkbox" data-cke-saved-name="office" name="office" value="" ';}="" ?="">

 

You should not be seeing the PHP code outputted at all.

 

This suggests to me either the file containing the php code does not have a  .php extension or your server is not configured correctly.

 

Can you tell use how you are accessing/running the php code?

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.