PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 5th, 2006, 11:15 AM
SnapCracker's Avatar
SnapCracker SnapCracker is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: Kent, United Kingdom
Posts: 165 SnapCracker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 21 h 22 m 31 sec
Reputation Power: 14
HTML form: One submit button, 2 actions

Hi, is it possible to make two actions take place (or at look like it) when the submit button is hit, after filling in text into a form, after which a little pop-up tells you that your info was sent and another, the window which contained the form, is redirected to another page.
here is the form:-
Code:
<form method="post" target="foo" onsubmit="window.open('','foo','resizable=0,scrollbars=2,wid  th=220,height=365')" action="thanksforyouremail6.php">
<input type="text" name="visitor" size="50">
<input type="text" name="visitormail" size="50" />
<textarea name="notes" cols="50" rows="18">Include Company name, telephone number and url of website/webpage.</textarea>
<input name="Send" type="submit" id="Send" value="Send" />
</form>

You can see I've got the pop-up window there, I just need the re-direct to another url (shopping cart site) at the same time. I have considered php- header("Location etc and also meta refresh but they both do it at the wrong time! What would be nice if I could put it into the javascript function window.open somehow. Could anyone help please.

Reply With Quote
  #2  
Old April 6th, 2006, 08:18 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 18
I'm going to have to say no... one form, one action.
However there may be a better way to do what you're trying to do.

I don't fully understand what you're trying to do though =)
Is it possible to give us a higher overview of what you're doing?
What's the popup for?
__________________
Daryl's Homepage | My Blogroll | My Profile | Firefox supporter!
DevArticles Forum Moderator

"The net is a waste of time, and that's exactly what's right about it." -- William Gibson

Reply With Quote
  #3  
Old April 6th, 2006, 09:59 AM
SnapCracker's Avatar
SnapCracker SnapCracker is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: Kent, United Kingdom
Posts: 165 SnapCracker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 21 h 22 m 31 sec
Reputation Power: 14
Hi MadCowDzz! long time no speak.
OK, the pop-up is a php file which validates the input from the text boxes and moans if text boxes not filled in etc, then if all's well composes email to me using the text from the form page. You can see it's quite a dinky little window, which invites you to close it if a button is clicked.
It would really nice if the submit button of the form could as well as generate this pop-up page (doing all the stuff it's written to), it could also direct the form page to another page not even having to use any of the values generated from the form (such as back to the homepage, or my case, a shopping cart).
At the moment, I have to have 2 buttons next to each other, one for submit info, and other, pay now. A bit untidy, and leaves the paying bit an option! not what I really want!

Reply With Quote
  #4  
Old April 7th, 2006, 05:39 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 1,029 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6
Time spent in forums: 1 Week 12 h 55 m 59 sec
Reputation Power: 15
Send a message via ICQ to Itsacon
Can be done easily.

In the onclick() for the submit button, you put a JS function that checks the validity of the entered data. If the data is valid, the function returns TRUE (and the browser will submit). If it's not valid, give a javascript.alert('Error: invalid input') and return FALSE (the browser will not submit then).

Remember to check the data on the other side as well though, since users may have disabled javascript.
__________________
This is my code. Is it not nifty?

"The biggest problem encountered while trying to design a system that was completely foolproof, was, that people tended to underestimate the ingenuity of complete fools."
---Douglas Adams


Join the Itsacon fanclub!    
Zero Tolerance: Spammers banned so far: 592

Reply With Quote
  #5  
Old April 7th, 2006, 08:10 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 18
Hey SnapCracker, welcome back... =)

I still don't see why you need the two actions. It sounds as though the page you are submitting to will validate and send the email... what would the OTHER page you're submitting to do?

If you simply want your results page in a popup (as not to disrupt the user's current session), a non-W3C-standard way to do it would be <form action="..." method="..." target="_blank">

I agree with Itsacon that supplementary client-side validation never hurts either

Reply With Quote
  #6  
Old April 7th, 2006, 12:21 PM
SnapCracker's Avatar
SnapCracker SnapCracker is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: Kent, United Kingdom
Posts: 165 SnapCracker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 21 h 22 m 31 sec
Reputation Power: 14
OK, both of you have been very helpful, thanks, however, I must have misled you as to what I was asking.
This is all about someone submitting data in the form, data being validated by php in the pop-up window and sending in a form of an email, and then user paying for what they have just sent. Hence, that's why I said that the original window re-directs to another page such as a shopping cart! I don't need any more help in validating the data input from the form, just some clever bit of code to do 2 things when the submit button is clicked in the form. Cheers

Reply With Quote
  #7  
Old April 11th, 2006, 08:06 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 18
Is this simply a shopipng cart application?

data being validated by php in the pop-up window and sending in a form of an email

Is this one script, or is this the two that you want to submit to? I think they should be on script.

Here's how I would advise the application flow...

Code:
User enters a form and presses submit... (to one action)
PHP Script receives data from user's form, validates
      If valid, pass to payment script
      If not valid, return to form with error

Payment script will present a form, user filles out data and presses submit
Validate again, etc etc... if valid, then send email to admin

Let me know if i'm still hitting way off in left field...
I see you say "original window redirects to shopping cart"... um... exactly what information is the first form receiving?

ultimately I suggest having one action per form (no choice anyways), and then having whatever script receives the data, to pass it around to the other scripts...
How do you pass (and persist) form data across pages? Easy, use session variables...

Are we getting anywhere, or am I still lost?

Reply With Quote
  #8  
Old April 11th, 2006, 10:02 AM
SnapCracker's Avatar
SnapCracker SnapCracker is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: Kent, United Kingdom
Posts: 165 SnapCracker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 21 h 22 m 31 sec
Reputation Power: 14
Is this simply a shopping cart application? it's RomanCart's very cheap and works.

data being validated by php in the pop-up window and sending in a form of an email Yes exactly, then it invites you close the window.

Is this one script, or is this the two that you want to submit to? I think they should be one script. not really, knowing above info.

Typing this explaination has rang a few bells! I have just realised; what happens when an invalid input is submitted and then the original window containing the form disappears and goes to the shopping cart for the user to pay what he has not actually sent: not good! Know wonder you were thinking "I don't get it!" I will have to connect the php validation to the start of the shopping cart. OK, I'll go away and think of a way of putting the validation in the original window, when the user, say, misses out a field, a star comes up next to it and gives an error. When the form is error free, then it will allow the page to be directed to the shoppingCart, maybe with the use of include "shoppingcart"; command.
Cheers for now.

Reply With Quote
  #9  
Old April 12th, 2006, 08:08 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 18
Why does the user send the order to you before he pays?
Wouldn't you want to know the user has paid before you receive the order?

Reply With Quote
  #10  
Old April 12th, 2006, 11:36 AM
SnapCracker's Avatar
SnapCracker SnapCracker is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: Kent, United Kingdom
Posts: 165 SnapCracker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 21 h 22 m 31 sec
Reputation Power: 14
OK, you've beaten it out me! The form consists of advertising information to be listed on my directory. I think the user would be more comfortable the submisson of information had gone though before he pays, and anyway, if the user does not pay, and as the information is manually added to a Filemaker database and hence matched up to a payment, the listing won't get added. The Filemaker database is converted to a CSV and then uploaded to the MySQL database online via phpMyAdmin. Abit messy, but enables me to control every step, especially when Filemaker takes all sorts of font characters, even different kinds of quotation marks. These can be 'find/replaced' in an editor before uploading so there are no weird characters showing up online where I don't want them to be. If you think that the Filemaker part can be by-passed and all the information can be updated directly, sure, this can be done easily enough with php, however, there would be no sync between telephone orders, and any other additions made using the user-friendly filemaker database and the MySQL database.

Reply With Quote
  #11  
Old April 12th, 2006, 11:53 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 18
I knew there was a hole there somewhere!
Your system sounds like quite a lot of manual workarounds...

Don't kill me, but I still think the information and payment can go through as one... I mean, it is still one transaction... but again, back to the discussion above, so the two actions are your payment system and your information submission system? (I finally think I get it )

Reply With Quote
  #12  
Old April 12th, 2006, 04:41 PM
SnapCracker's Avatar
SnapCracker SnapCracker is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: Kent, United Kingdom
Posts: 165 SnapCracker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 21 h 22 m 31 sec
Reputation Power: 14
Manual workarounds? Hands on supervisory use of various applications! Well we got do something for a living. What I would like to do is write a php page on the web server that I have log on to that would invite the user to choose the CSV filename from the host PC and rename the current MySQL database and upload the new one. Should be easy enough but I have too busy just getting the website working and looking good.
It's OK now it's given me a good reason now to change the way it all works, to keeping it all in the same window and not having these pop-ups that nobody like anyway.

Reply With Quote
  #13  
Old July 27th, 2006, 08:16 AM
G33K G33K is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 1 G33K User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 20 sec
Reputation Power: 0
Might have A solution

I needed one button to do two actions and this worked for me, I am a noob but here is my code.

<form enctype="multipart/form-data" action="sendmail.php", "<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST">

(I just added the two action with a comma)

and this is for the button

<INPUT TYPE="submit" VALUE="Submit" value="Upload">

Basically I email a message and send a file that is uploaded to a directory on my server.

Hope this helps.


G33K!

Reply With Quote
  #14  
Old July 27th, 2006, 12:37 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 18
G33K, does that work in all browsers?
I wouldn't expect that behaviour, and certainly wouldn't trust it....

Reply With Quote
  #15  
Old August 4th, 2006, 07:24 AM
SnapCracker's Avatar
SnapCracker SnapCracker is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: Kent, United Kingdom
Posts: 165 SnapCracker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 21 h 22 m 31 sec
Reputation Power: 14
Quote:
Originally Posted by G33K
I needed one button to do two actions and this worked for me, I am a noob but here is my code.
G33K!


Thanks for that, I'll see if it works for me and in all browsers. I'm honoured that you registered in order for you to tell me this!

Reply With Quote
  #16  
Old August 4th, 2006, 07:57 PM
colton22's Avatar
colton22 colton22 is offline
\ ^_^ / - *Local Friend*
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Location: near chicago, Illinois
Posts: 469 colton22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 36 m 37 sec
Reputation Power: 13
Send a message via AIM to colton22 Send a message via MSN to colton22 Send a message via Yahoo to colton22
im wondering if that will work in html too, lol, ill try it out.

colton22

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > HTML form: One submit button, 2 actions


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap