-
Form page acting funny!
Hey, can anybody tell me why this scrip isn't working? I'm sure the code is right, but when the page is opened in a browser, the php code is filled it the text field. Also the php code shows up in the html source code (?). I'm using Wordpad as my text editor and saving my files as text files with a .php extention (my_file.php). Can anyone help?
<body>
<h1>Reverse String</h1><hr />
<?php
if (!isset($_GET['input_text']))
echo "<p>Enter the string you want to reverse.</p>";
else{
$ForwardString = $_GET['input_text'];
$ReverseString = strrev($ForwardString);
echo "<p>'$ForwardString' spelled backwards is '$ReverseString'.</p>";
}
?>
<form action="ReverseString.php" method="get" enctype="application/x-www-form-urlencoded">
<p><input type="text" name="input_text" size="20" value="<?php if (!empty($_GET['input_text'])) echo $_GET['input_text'] ?>" /></p>
<p><input type="submit" value="Reverse String" /></p>
</form>
-
Do you have a link to the page?
-
-
You might want to check with your host to make sure it supports PHP.
-
Indeed, this looks that that is the case. If they say they do support PHP, make a new file called info.php and place this in it:
Code:
<?php
phpinfo();
?>
if you get a blank page, then they are lying. Otherwise, further troubleshooting will be required.
-
That's what I thought at first. But my previous and simpler scrips were working fine. I already contacted my web host (Bravenet) and the said PHP was working fine. I also tried the code on another server (Go Daddy) and got the same results...the simpler scrips work but the ones with forms don't. This is really gettin' frustrating!
-
Btw, I DID try the code you gave me and it worked. I got to the PHP info page.
-
Ok, then you will need to post the entire code for the page so that we can see what is the cause of your problem. Be sure to remove any usernames and passwords.
-
I really appriciate you checking it out!
Here's my code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtmll/DTD/xhtmll-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Logical Examples</title>
</head>
<body>
<h1>Reverse String</h1><hr />
<?php
if (!isset($_GET['input_text']))
echo "<p>Enter the string you want to reverse.</p>";
else{
$ForwardString = $_GET['input_text'];
$ReverseString = strrev($ForwardString);
echo "<p>'$ForwardString' spelled backwards is '$ReverseString'.</p>";
}
?>
<form action="ReverseString.php" method="get" enctype="application/x-www-form-urlencoded">
<p><input type="text" name="input_text" size="20" value="<?php if (!empty($_GET['input_text'])) echo $_GET['input_text'] ?>" /></p>
<p><input type="submit" value="Reverse String" /></p>
</form><hr />
</body>
</html>
-
I can't figure it out. I used the code you posted and it worked perfectly on my servers. I didn't modify anything and it worked fine; so that means the code is code (other than the XHTML standard you are using; which Twey can explain more about this). As for the PHP, there is nothing wrong with it as I tested on several servers and it worked fine.
Sorry I couldn't be of more help.
-
Thanks anyway for looking into for me. I really appriciate it. At least now I know it's NOT my code. That helps!
-
Wow, finally figured it out! My text docs weren't being registered properly. I tried saving a file with one that was already open, but instead of it not letting me save the file, it saved it anyway but said that it couldn't register it. With the file created with the proper name, I thought all was well and dandy. Much to my dismay... I just copied my file to another WordPad doc and it WORKED!
Thanks again for your help. I wouldn't have thought of fixing it the way I did without it!
-
if it still not working for you Daryl,
you might want to delete your cookies, try that and see if it works...
oh it works for me..
-
Instead of using wordpad, you may want to use a pure plain text editor such as notepad, notepad++, bbedit, etc. That way there is no mistake in the file format when you save it.
Just my two cents worth of advise.
-
wordpad has done some weird things to my code in the past.
-