View Full Version : Form page acting funny!
Daryl
09-21-2007, 10:48 PM
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>
thetestingsite
09-21-2007, 10:50 PM
Do you have a link to the page?
Daryl
09-21-2007, 10:52 PM
Yeah, here's the address:
http://www.jewellikeit.com/php/ReverseString.php
alexjewell
09-21-2007, 10:57 PM
You might want to check with your host to make sure it supports PHP.
thetestingsite
09-21-2007, 11:01 PM
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:
<?php
phpinfo();
?>
if you get a blank page, then they are lying. Otherwise, further troubleshooting will be required.
Daryl
09-21-2007, 11:21 PM
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!
Daryl
09-21-2007, 11:24 PM
Btw, I DID try the code you gave me and it worked. I got to the PHP info page.
thetestingsite
09-21-2007, 11:25 PM
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.
Daryl
09-21-2007, 11:29 PM
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>
thetestingsite
09-22-2007, 04:02 PM
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.
Daryl
09-23-2007, 04:54 AM
Thanks anyway for looking into for me. I really appriciate it. At least now I know it's NOT my code. That helps!
Daryl
09-23-2007, 06:13 AM
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!
insanemonkey
09-23-2007, 01:17 PM
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..
thetestingsite
09-23-2007, 02:30 PM
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.
djr33
09-23-2007, 05:41 PM
wordpad has done some weird things to my code in the past.
alexjewell
09-24-2007, 01:40 AM
notepad++ is my preference.
http://notepad-plus.sourceforge.net/uk/site.htm
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.