Jump to content

PHP Question


Vince889

Recommended Posts

Okay, I have a form that submits to another page for processing.

 

Just as an example

 

the page looks like

<form action="process.php" method="post">
<textarea rows="25" cols="40" name="sometext">Some text goes here</textarea><br />
<textarea rows="25" cols="40" name="sometext2">Some text goes here</textarea
<input type="checkbox" name="option" value="option">

 

the process.php page would look something like:

 

<?php
$sometext = $_POST['sometext'];
        $sometext2 = $_POST['sometext2'];
$option = $_POST['option'];
if (strcmp($sometext, $sometext2) == 0) {
    echo 'The original document and the secondary document matches.';
}
else {
echo 'The secondary document differs from the original document. It has been altered.'; }
?>

Not that I didn't know how to add the $option variable in. I was thinking of elseif.. but i don't know

 

My problem is,

How do I get PHP to check if the box was checked or not. And how do I make another operation INSTEAD of

 

if (strcmp($sometext, $sometext2) == 0) {
    echo 'The original document and the secondary document matches.';
}
else {
echo 'The secondary document differs from the original document. It has been altered.'; }

 

 

 

For example, if PHP sees the checkbox unchecked, it would excute

if (strcmp($sometext, $sometext2) == 0) {
    echo 'The original document and the secondary document matches.';
}
else {
echo 'The secondary document differs from the original document. It has been altered.'; }

 

but if the checkbox was checked, it would execute

 

if (strcasecmp($sometext, $sometext2) == 0) {
    echo 'The original document and the secondary document matches.';
}
else {
echo 'The secondary document differs from the original document. It has been altered.'; }

 

 

Someone help please. I hope i was clear.... >_>

 

-------

 

edit:

would i add this to process.php

 

elseif (!isset($option)) { (strcasecmp($sometext, $sometext2) == 0) {
    echo 'The original document and the secondary document matches.';
}
else {
echo 'The secondary document differs from the original document. It has been altered.'; }
    
} 

 

would that work if i checked to see if the &option was set (checked)?

Link to comment
https://forums.phpfreaks.com/topic/120018-php-question/
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.