|
-
Nov 21st, 2002, 01:01 PM
#1
Thread Starter
Hyperactive Member
submitting a form in PHP?
-
Nov 21st, 2002, 01:04 PM
#2
Stuck in the 80s
Yes...
Set your form up: <form action="page.php" method="post">
and get the form stuff like:
Code:
echo $_REQUEST['field_name'];
Or just do a search of these forums or read the manual: http://www.php.net/
submitting/reading forms is rather elementary.
-
Nov 21st, 2002, 01:23 PM
#3
Frenzied Member
Re: submitting a form in PHP?
Originally posted by Dodger
Can it be done?
TIA.
NO, if you do it you will be the 1st EVER to do it in php. you better write a book
-
Nov 21st, 2002, 01:26 PM
#4
Stuck in the 80s
Sorry, I was in a bit of a hurry before.
Here's something basic:
Code:
//let's call this bung.php
if (isset($_REQUEST['submit'])) {
//the form was sent:
echo "What's up, " . $_REQUEST['name'] . "?!";
} else {
echo '<form action="bung.php" method="post">
<input type="text" name="name"><br>
<input type="submit" value=" Submit ">
</form>';
}
Basically all there is to it.
-
Nov 21st, 2002, 01:36 PM
#5
Thread Starter
Hyperactive Member
The Hobo,
You saying the form will be automatically submitted just by echoing it?
-
Nov 21st, 2002, 01:38 PM
#6
Frenzied Member
no, to submit it you have to push on the submit button.
just like a html form no different
-
Nov 21st, 2002, 01:39 PM
#7
Thread Starter
Hyperactive Member
I found a script at PSC that can do it through code.
-
Nov 21st, 2002, 01:41 PM
#8
Frenzied Member
and how is that? you have to click on something. what would the purpose to submitting the form is if the user doesn't get a chance to insert the info?
-
Nov 21st, 2002, 01:41 PM
#9
Stuck in the 80s
Originally posted by Dodger
The Hobo,
You saying the form will be automatically submitted just by echoing it?
What phpman said. After you submit the form, the values that were in that form are stored in what is referred to as "super globals." Like $_REQUEST, $_POST, and $_GET, depending on how you setup the form. $_REQUEST holds both $_POST and $_GET variables, and a few others.
So once you submit the form, you have to check in your php file to see if it was submitted, and act accordingly. If the form has been submitted, these global variables are available for use in the php program for that time.
-
Nov 21st, 2002, 01:42 PM
#10
Stuck in the 80s
Originally posted by Dodger
I found a script at PSC that can do it through code.
What I showed you is doing it through code. Do you not see the code?
-
Nov 21st, 2002, 01:43 PM
#11
Stuck in the 80s
Originally posted by phpman
and how is that? you have to click on something. what would the purpose to submitting the form is if the user doesn't get a chance to insert the info?
My best bet is that he found some JavaScript code and is confusing it with PHP...
-
Nov 21st, 2002, 01:45 PM
#12
Thread Starter
Hyperactive Member
Hey, don't be rude...lol
I'm new to PHP...not that new!
The script I found takes the URL and an associative array containing the input values, opens a socket connection and posts a request to the server.
-
Nov 21st, 2002, 01:46 PM
#13
Frenzied Member
ok see, they have to push submit to get the input values to go anywhere.
what you are doing is the long way around and harder.
-
Nov 21st, 2002, 01:47 PM
#14
Stuck in the 80s
Originally posted by Dodger
Hey, don't be rude...lol
I'm new to PHP...not that new!
The script I found takes the URL and an associative array containing the input values, opens a socket connection and posts a request to the server.
...
What does this have to do with submitting a form?
"opens a socket connection and posts a request to the server"
Did you, by chance when you posted this thread, ask the wrong question or neglect to elaborate on your question?
-
Nov 21st, 2002, 01:48 PM
#15
Thread Starter
Hyperactive Member
The Hobo,
No I didn't, I was asking for code to simulate a form submission.
D.
-
Nov 21st, 2002, 01:50 PM
#16
Stuck in the 80s
Originally posted by Dodger
The Hobo,
No I didn't, I was asking for code to simulate a form submission.
D.
You asked if it was possible to submit a form in PHP.
Yes. Hit the submit button...
-
Nov 21st, 2002, 01:50 PM
#17
Thread Starter
Hyperactive Member
*sigh*
I have a 'quick register' form at my site, I am simply looping through a member database and submitting the form for each member.
D.
-
Nov 21st, 2002, 01:52 PM
#18
Stuck in the 80s
Originally posted by Dodger
*sigh*
I have a 'quick register' form at my site, I am simply looping through a member database and submitting the form for each member.
D.
That makes no sense...
Why don't you just do it in code? Are you creating a form, putting the values in the fields, and simulating a submit?
Again, that makes no sense.
-
Nov 21st, 2002, 01:56 PM
#19
Frenzied Member
you didn't say anything about a simulation?
-
Nov 21st, 2002, 01:56 PM
#20
Thread Starter
Hyperactive Member
The registration script is not made by myself, it has various functions, it's not a simple sql insert. It's possible to include the registration page and call the register function, but I think the script expects values in the $_POST variables.
-
Nov 21st, 2002, 01:58 PM
#21
Frenzied Member
well yeah, you could have teh form submtted by the user and then in the php check script you can send variabels to the function
so the scruipt that simulates a submit, does it expects a return answer, becasue that is pretty much what teh socket connection is doing.
still don't make any sense to what you are doing.
-
Nov 21st, 2002, 02:04 PM
#22
Thread Starter
Hyperactive Member
yes the script does ask for ther result of the request.
-
Nov 21st, 2002, 02:05 PM
#23
Frenzied Member
so how are you sending the form info?
-
Nov 21st, 2002, 02:11 PM
#24
Stuck in the 80s
I'm just not understanding what he's doing and why he's doing it, so I'll leave this thread up to you, phpman.
-
Nov 21st, 2002, 02:12 PM
#25
Frenzied Member
me?? I don't understand either
-
Nov 21st, 2002, 02:16 PM
#26
Thread Starter
Hyperactive Member
lol, don't worry guys, I'll try some other way.
Thanks.
-
Dec 20th, 2002, 07:09 PM
#27
New Member
I think I know what you're trying to do. Correct me if I'm wrong..
You have a database with users or something like that in there. You want to submit the data from each of these records to another form. To do this you want to "fake" the submission of a form (ie open a web page and supply the form values without requiring a form to be displayed and clicking on the submit button)
Am I right??
I know how to do this in Visual Basic - you can use the WebBrowser control to open a page and specify optional headers (Eg the form values in the POST header.) As for doing it in PHP..? I have no idea.
Why not just modify the script to read the entries from the database and process them one by one within that same script. Would be easier in the long run I think.
Matt
-
Dec 23rd, 2002, 12:38 PM
#28
Frenzied Member
if you understood that then you get the booby prize LOL
I still don't know what he wants.
-
Dec 23rd, 2002, 12:52 PM
#29
Thread Starter
Hyperactive Member
That's it, Matt.
I ended up adding the records to the db directly once I figured out which fields were required.
Thx.
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
|
Click Here to Expand Forum to Full Width
|