?
Solved

PHP Code

Posted on 2012-12-24
5
Medium Priority
?
284 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 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 1336 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 664 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 111

Accepted Solution

by:
Ray Paseur earned 1336 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 111

Expert Comment

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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
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 …
Suggested Courses
Course of the Month15 days, 22 hours left to enroll

850 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