Solved

PHP Code

Posted on 2012-12-24
5
263 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

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 …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

829 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