Vince889 Posted August 17, 2008 Share Posted August 17, 2008 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 More sharing options...
PC Nerd Posted August 17, 2008 Share Posted August 17, 2008 if(isset($_POST['option']) && $_POST['option'] == 'option') { do code; } else { // not checked do other code; } i beleive that shoudl work. Link to comment https://forums.phpfreaks.com/topic/120018-php-question/#findComment-618272 Share on other sites More sharing options...
Vince889 Posted August 17, 2008 Author Share Posted August 17, 2008 It did! Thanks a lot, man! Link to comment https://forums.phpfreaks.com/topic/120018-php-question/#findComment-618283 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.