Hi all,
I have recently started looking at php etc so bear with me. I have created apage which launches a popup window. On this window a user can enter information into a text box. When the user clicks a button I want to be able to grab the info in the text box and then fire it back into a database. I then want to close the pop up window and return focus to the original calling page.
Whilst I am ok to insert the data to the database i am struggling to actually get back the info from the form (never was nay good with forms)
Appreciate any help with this, as its causing me sleepless nights
Thanks
Ian
noobie looking for help
Moderator: General Moderators
well.. to start with, if you create the pop up via javascript, then you close it via javascript
now you just need to use that $_POST[] array to tell when to give the user the close link.
i would have a error checking functionin the pge so that when it calls itself it'll check for errors and return them if there were any
and call a different function to make the page if it was all good, and that function will give the close link as well as letting the user know it was successful
now you just need to use that $_POST[] array to tell when to give the user the close link.
i would have a error checking functionin the pge so that when it calls itself it'll check for errors and return them if there were any
and call a different function to make the page if it was all good, and that function will give the close link as well as letting the user know it was successful
-
lemonsprig
- Forum Newbie
- Posts: 2
- Joined: Mon Jul 28, 2003 1:17 pm
ok to uncofuse my simple mind a little lets take a step back and ignore the opening and closing of the pop up.
I am trying to test this with the following code
<form action="" method=POST>
<input type="text">
<select name="size">
<option value="small">small</option>
<option value="medium">medium</option>
<option value="large">large</option>
</select>
<input type="submit">
</form>
<?php
echo "$_POST[0]"
?>
when i click the submit button it simply blanks what is in the text box. And the echo function displays nothing.. I am wondering if somethinf fundamental is flawed with my thinking here
I am trying to test this with the following code
<form action="" method=POST>
<input type="text">
<select name="size">
<option value="small">small</option>
<option value="medium">medium</option>
<option value="large">large</option>
</select>
<input type="submit">
</form>
<?php
echo "$_POST[0]"
?>
when i click the submit button it simply blanks what is in the text box. And the echo function displays nothing.. I am wondering if somethinf fundamental is flawed with my thinking here
-
rob.weaver
- Forum Newbie
- Posts: 8
- Joined: Tue Apr 22, 2003 11:18 am
- Location: Houston, TX USA
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
You need to give your form elements names so that they can be identified by PHP. Try this:
Now for when the form is submitted you can do:
Mac
Code: Select all
<form action="<?php echo $_SERVERї'PHP_SELF']; ?>" method="POST">
<input type="text" name="textinput" />
<select name="size">
<option value="small">small</option>
<option value="medium">medium</option>
<option value="large">large</option>
</select>
<input type="hidden" name="action" value="post" />
<input type="submit" />
</form>Code: Select all
<?php
if (!empty($_POST['action']) && $_POST['action'] == 'post') {
echo 'The value of $_POST[''textinput''] is: '.$_POST['textinput'];
echo '<br />';
echo 'The select value chosen was: '.$_POST['size'];
}
?>