Solved

PHP Code

Posted on 2012-12-24
5
262 Views
Last Modified: 2013-01-20
Hi,

I put together a small app, but I want to make sure once a person hits the SUBMIT button it redirects to a processing message/page.  Does anyone have a code snippet for this?

Thanks
0
Comment
Question by:Jack_son_
  • 3
5 Comments
 
LVL 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 334 total points
ID: 38719111
When the submit control is fired, the browser will direct all of the form contents to the URL of the action= attribute of the form tag.  It is explained here at PHP.net (See "Dealing with Forms")
http://php.net/tut.php
0
 
LVL 31

Assisted Solution

by:Marco Gasi
Marco Gasi earned 166 total points
ID: 38719113
I'm not sure about what you want, but a submit button is usually part of a form so I think you ahve something like this:

<form action="" method="post">
  <input type="checkbox" name="" value="" />
  <input type="radio" name="" value="" />
  <input type="text" name="" value="" />
  <input type="submit" name="submit" value="Submit" />
</form>

In order or process form data you have to set the action attribute of the form to the script which does the job:

<form action="myscript.php" method="post">

That's all, but I suppose now you'll ask something about myscript.php... :-)

Cheers
0
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 334 total points
ID: 38719117
If the action= attribute of the form tag is empty or omitted, the request will be send to the current URL.  This allows you to put the form script and the action script into the same script file.  Very handy for keeping your work organized!

Merry Christmas wishes to all, ~Ray
0
 

Author Comment

by:Jack_son_
ID: 38721308
Thanks, everyone.  Yes, what is your script, that would help a lot!

Here is what i have in the code at the bottom, when I hit submit, I would like it to revert to the processing screen since there is a small delay and then go to the next screen:

<body>
    <form name="formOnlinePayment" method="post" action="OnlinePaymentConfirmation.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="formOnlinePayment">
<div>
======================

<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['formOnlineRequest'];
if (!theForm) {
    theForm = document.formOnlineRequest;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]>
</script>

========================================

<a class='default' href='javascript:document.forms[0].submit();'>Save Changes</a>
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 38799018
Thanks for the points, ~Ray
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now