473,387 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Do I need $_GET[" "]; autoglobal with php embedded form page?

7
Howdy, just wondering if someone can help me get this form working. Everything is right, I think, except for the autoglobal.

Expand|Select|Wrap|Line Numbers
  1. <body>
  2. <h1>Reverse String</h1><hr />
  3. <?php
  4. $ReverseString = $_GET["input_text"]; // I think this is where the problem lies
  5. if (!isset($_GET['input_text']))
  6.      echo "<p>Enter the string you want to reverse.</p>";
  7. else{
  8.      $ForwardString = $$_GET['input_text'];
  9.      $ReverseString = strrev($ForwardString);
  10.      echo "<p>'$ForwardString' spelled backwards is '$ReverseString'.</p>";
  11. }
  12. ?>
  13. <form action="ReverseString.php" method="get" enctype="application/x-www-form-urlencoded">
  14. <p><input type="text" name="input_text" size="20" value="<?php if (!empty($_GET['input_text'])) echo $_GET['input_text'] ?>" /></p>
  15. <p><input type="submit" value="Reverse String" />
  16. </form><hr />
  17. </body>
  18.  
Sep 16 '07 #1
6 2015
ak1dnar
1,584 Expert 1GB
Check this out: I made some changes to your original script. If there any doubt feel free to ask after going through this.

ReverseString.php
Expand|Select|Wrap|Line Numbers
  1. <body>
  2. <h1>Reverse String</h1><hr />
  3. <?php
  4. if(isset($_GET['submit_button'])){
  5.     $ForwardString = $_GET['input_text'];
  6.     if (!empty($ForwardString)){
  7.     $ReverseString = strrev($ForwardString);
  8.     echo "<p>'$ForwardString' spelled backwards is '$ReverseString'.</p>";
  9.     }else{
  10.     echo "<p>Enter the string you want to reverse.</p>";
  11.     }
  12. }
  13. ?>
  14. <form action="ReverseString.php" method="get" enctype="application/x-www-form-urlencoded">
  15. <p><input type="text" name="input_text" size="20" value="<?php if (!empty($_GET['input_text'])) echo $_GET['input_text'] ?>" /></p>
  16. <p><input name="submit_button" type="submit" value="Reverse String" />
  17. </form><hr />
  18. </body>
  19.  
Sep 16 '07 #2
Atli
5,058 Expert 4TB
Hi Daryl.

The only thing I could see wrong with your original code is that you have and extra $ in line 8. Should have caused a Syntax error if you have error messages enabled.

I would, however, recommend checking out the code ajaxrand posted and adopt some of the changes he made.

Also, consider using POST rather than GET. It is a much better way of sending text.
Sep 16 '07 #3
daryl
7
Thanks guys for replying. I was hoping it was just the $ sign...but no. wow ajaxrand, thanks for your input, although I'm not that good yet to decifer exactly what you did. This code is actually for part of a school project and I think everything was right except for line 4. I just kinda guessed at it. I took it out and it seems to make no difference in the results. I tried your code too. Same thing happens, the php script reads out in the text field. I've tried everything that I know. Any ideas?
Sep 16 '07 #4
Atli
5,058 Expert 4TB
What exactly is the problem?
Are you getting any error messages?

If you are not sure about this form stuff, check out this article I wrote about them.
Sep 17 '07 #5
daryl
7
No error messages. Just when I open the page, the text field that a user enters the info into is already filled....with the php script that's embedded in the input tag on line 14.

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php if (!empty($_GET['input_text'])) echo $_GET['input_text'] ?>
  3.  
  4.  
Sep 17 '07 #6
ak1dnar
1,584 Expert 1GB
No error messages. Just when I open the page, the text field that a user enters the info into is already filled....with the php script that's embedded in the input tag on line 14.

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php if (!empty($_GET['input_text'])) echo $_GET['input_text'] ?>
  3.  
  4.  
Why we using this line to re-dispaly the user entered data once you pressed the button. but It'll never display any INPUT when you loading the page for first time. I think you are using the the code my previous coding instead of yours now. Any Quiz?
Sep 17 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

32
by: Nuno Paquete | last post by:
Hi group. I'm using this code to see if is there any parameter for variable "menu": if($_GET == "downloads") .... But this code log errors if there is no parameter passed (this heappens at...
1
by: lawrence k | last post by:
If I copy and paste this url into my browser: http://www.bluecasts.com/index.php?templateId=PT_distroDemo.txt&amp;distroTitle=priceTitle.php&amp;distroMainContent=prices.php and I've a simple page with...
7
by: John | last post by:
Hi I have forgotten how to do this. Got a <form ... > with <input type="button" name="Hit Me" onclick="whatever()"> </form> The output of the Javascript function 'whatever' appears on...
8
by: Zytan | last post by:
In VB, you use ControlChars.CrLf (or better, ControlChars.NewLine). In C/C++, we are used to using merely "\n" (or at least I am). It appears "\n" is good enough for RichTextBoxes. Does it...
12
deephill
by: deephill | last post by:
hi i need form dependency. Can u check below code? <p>1. Are you married?</p> <p>
1
by: Jenny | last post by:
Dear all, I have one select which lists one visible element. I want this select can show scrollbar after I click its down arrow, so that i can use the scrollbar to select the element i want. ...
4
by: Irfan12 | last post by:
I am using the following PHP code to force the internet browser to download a media file(e.g, .mp3, .wma), But in this code, there is no resume support in downloading these files. i dont know PHP,...
79
truthlover
by: truthlover | last post by:
I need some help. I need a button on an Access form that allows the user to browse for a file on our network, and insert it in a field (rather than having to type a path). I dont need any filters...
13
by: Kurda Yon | last post by:
Hi, I found one example which defines the addition of two vectors as a method of a class. It looks like that: class Vector: def __add__(self, other): data = for j in range(len(self.data)):...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.