If Statements input box
I'm trying to get the php results of if statements into an input box. i tried using the $translateen as the value of the input shown below. but it does not work. i am very new to php and i would appreciate any help given.
<?php
$capseng = $_POST["english"];
$capseng = strtolower($capseng);
$english = $capseng;
if ($english == "goodbye")
echo "au revoir";
elseif ($english =="Good day") ($translateen = "Bonjour");
elseif ($english =="a") echo stripslashes("quelqu\'un, dans, un ");
else
echo "Not Found";
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<input type="text" name="english" maxlength="50" size="30"
style="height: 42px; width: 233px" align="top" value="<?php echo $translateen;?>">
</body>
</html>
Please don't get upset by my asking this question. I actually ran into this situation, once before.
Is the document that you are working on saved as a .php file, or .html file?
it is saved as a php file.
Based on what I think you want to do, this fixes a few things and is a bit cleaner and clearer, I think:
PHP Code:
<?php $english = "" ; if(isset( $_POST [ "english" ])){ $english = strtolower ( $_POST [ "english" ]); } $translateen = "" ; if ( $english == "goodbye" ) { $translateen = "au revoir" ; } elseif ( $english == "good day" ) { // must be lower-case! $translateen = "Bonjour" ; } elseif ( $english == "a" ) { $translateen = "quelqu'un, dans, un " ; } elseif( $english !== "" ) { $translateen = "Not Found" ; } ?> <html xmlns="http://www.w3.org/1999/xhtml"> <body> <!-- need a form tag! --> <form action='' method='post'> <input type="text" name="english" maxlength="50" size="30" style="height: 42px; width: 233px" align="top" value="<?php echo $translateen ; ?> "> </form> </body> </html>
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in
Nation
eBookworm.us
wow thanks. that works perfectly, and I don't need the strip-slashes any more to display Apostrophes.
What I can suggest you that make sure if you saved your file .php or not ..otherwise make it sure you put filename between inverted comma when you save file in any text editor.
robotforce i clearly stated that i had saved it as a php file. The problem was resolved two days ago.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks