473,405 Members | 2,294 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,405 software developers and data experts.

Form Action

i am somewhat new to php.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. echo"
  4.  
  5. <span class='sif'>
  6.     <form method='post' action='index.php?username='>
  7.         Username <input type='text' name='username2'><br />
  8.         Password <input type='password' name='password2'><br />
  9.         <input class='sub' type='submit' value='Submit'>
  10.     </form>
  11. </span>
  12.  
  13.  
  14. ";
i am trying to use GET in the action of the form with a variable that is not created until after the form submits.

i want it to look like this. (change is in the action)

Expand|Select|Wrap|Line Numbers
  1. <form method='post' action='index.php?username=$TheirUsername'>
May 13 '10 #1

✓ answered by Atli

Hey.

If you use the GET method instead of the POST method, your browser will automatically attach the variables to the URL. Although, considering that you are doing a login form, I would advice against that. All the fields will be added to the URL, not just the username, so the password will be (more) plainly visible.

When you use the POST method, you use the $_POST array in PHP to fetch the data, not the $_GET array.

If you really want to add the value of an input box to the form's action box before it is sent, you going to have to use JavaScript. PHP and HTML alone can't do that for you.

4 1728
dlite922
1,584 Expert 1GB
how is the variable created then? Where is it coming from?

What part are you having trouble with? i.e. what can't you do?




Dan
May 13 '10 #2
i want to have their username or what they put into the form to be set in the action of the form so it sends them to a page index.php and i have a $_GET on another page (index.php) that will receive what their username by the ?username= in the URL.

i am having trouble with how i would get a variable that isnt created until the form is complete to be inserted into the first part of the form.
May 13 '10 #3
Atli
5,058 Expert 4TB
Hey.

If you use the GET method instead of the POST method, your browser will automatically attach the variables to the URL. Although, considering that you are doing a login form, I would advice against that. All the fields will be added to the URL, not just the username, so the password will be (more) plainly visible.

When you use the POST method, you use the $_POST array in PHP to fetch the data, not the $_GET array.

If you really want to add the value of an input box to the form's action box before it is sent, you going to have to use JavaScript. PHP and HTML alone can't do that for you.
May 13 '10 #4
@Atli
i didnt think i could. but i thought i would try. thanks for your time and the help
May 14 '10 #5

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

Similar topics

1
by: rickr | last post by:
In the form tag, the action attribute. >-----Original Message----- >When create .aspx file, how to specify the action in the >form action=?????>/form>? Anyone? Thanks. > >Rickr >. >
5
by: bissatch | last post by:
Hi, I have been trying to come up with an idea to reduce double submissions where a user clicks refresh and, for example, another row is INSERT into a table. Originally, I would have a form...
10
by: iam247 | last post by:
Hi In my prototype asp page (with no javascript and no password validation, I have a registration form with the following action: <form name="form" method="post" action="RegDetails.asp"> ...
2
by: iam247 | last post by:
Hi In my prototype asp page (with no javascript and no password validation, I have a registration form with the following action: <form name="form" method="post" action="RegDetails.asp"> ...
2
by: belgie | last post by:
Whereas in Asp I could submit my form contents to any other Asp page, it appears that in Asp.NET the primary Asp form will only submit to itself. I have tried changing the Action attribute in the...
2
by: Matt | last post by:
I have a client that requires a custom extension to all of the aspx pages. I have created an HttpHandler to receive the custom extension but where do I capture the response of the form with an...
4
by: Bosconian | last post by:
I have created a form tool page that consists of several dropdowns which allows a user to drill down and select a desired document for viewing in an external window. I need to post the form data to...
4
by: wwwmike | last post by:
How can I overwrite the <FORM action=attribute? I can add new attributes with Dim xx As System.Web.UI.HtmlControls.HtmlForm xx = Page.FindControl("form1") xx.Attributes.Add("something",...
6
by: Arthur | last post by:
Hello. How might it be possible to change where a form action is directed based on a selected option. For example I have this: <FORM METHOD = "post" ACTION = ""> And a drop down such as
18
by: vetrib2w | last post by:
Hi , In short: How to change the form action attribute value using javascript and that need to supported in IE also ? BRIEF: I am using ajax function to submit the form. I am also...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.