Form submission .

V

Vince Morgan

Hi all,
I have a form with about 10 fields. When I submit this form I
would like it to send the cgi data for processing, and remain static.
The form in part below;

<form method="post" name="MSDSform" action="dummy.php" onSubmit="return
checkSubmit();">
<!-- inputs and selects -->
<input type="submit" value=" Submit ">

When I click the " Submit " button the browser jumps to nowhere, whereas I'd
like it to just relax and sit there waiting for further entries.
My html experience could be scratched onto a grain of rice with a broom
handle, but I'm learning,, errr,, slowly.
I realize this is a mixture of html and cgi, but it's the html part that's
giving me the grief.
Any help is very much appreciated,
Regards,
Vince Morgan
 
S

Sandeep

Vince said:
Hi all,
I have a form with about 10 fields. When I submit this form I
would like it to send the cgi data for processing, and remain static.
The form in part below;

<form method="post" name="MSDSform" action="dummy.php" onSubmit="return
checkSubmit();">
<!-- inputs and selects -->
<input type="submit" value=" Submit ">

Check the return value for your function "checkSubmit", if it is always
false, your form would never be submitted
 
V

Vince Morgan

Sandeep said:
Check the return value for your function "checkSubmit", if it is always
false, your form would never be submitted
Yes, the function checkSubmiit() returns true when the conditions are
correct, and the form posts the data accordingly.
That part is working fine. However, I don't think I explained my problem
very well initialy.
Presently, at the moment of submision, my page wants to jump to another page
and throws a "HTTP 404". I would like it to post the data, and then wait
for further submisions, ie remain static.
Thanks,
Vince Morgan
 
J

Jonathan N. Little

Vince said:
Yes, the function checkSubmiit() returns true when the conditions are
correct, and the form posts the data accordingly.
That part is working fine. However, I don't think I explained my problem
very well initialy.
Presently, at the moment of submision, my page wants to jump to another page
and throws a "HTTP 404". I would like it to post the data, and then wait
for further submisions, ie remain static.

Well of course if "dummy.php" doesn't exist you'll get a 404. Your
form's ACTION *must* point to a real file! Now is can be the *same* file
as your original form, i.e., post to itself.
 
V

Vince Morgan

Well of course if "dummy.php" doesn't exist you'll get a 404. Your
form's ACTION *must* point to a real file! Now is can be the *same* file
as your original form, i.e., post to itself.
Thank you Jonathan,
Well, dummy.php did exist, just not in that directory. Stupid, stupid, etc.
That said it still won't do what I want.
Is it at all possible to create a page, with inputs, that will allow me to
add data and post it without the page wanting to change?
A static type page from which I can post data?
I actualy thought this would be quite easy.

Regards,
Vince Morgan
 
T

The Eclectic Electric

Vince Morgan said:
Thank you Jonathan,
Well, dummy.php did exist, just not in that directory. Stupid, stupid,
etc.
That said it still won't do what I want.
Is it at all possible to create a page, with inputs, that will allow me to
add data and post it without the page wanting to change?
A static type page from which I can post data?
I actualy thought this would be quite easy.

Could you maybe make dummy.php save the form variables to session variables
(and do whatever other processing you're wanting to do), send a redirect
header in dummy.php to your original form page and then use those session
varables to fill the form values? Is that anything like you need?

+e
 
J

Jonathan N. Little

Vince said:
Thank you Jonathan,
Well, dummy.php did exist, just not in that directory. Stupid, stupid, etc.
That said it still won't do what I want.
Is it at all possible to create a page, with inputs, that will allow me to
add data and post it without the page wanting to change?
A static type page from which I can post data?
I actualy thought this would be quite easy.

Look Vince if you want a form to actually submit the data the URL will
change to whatever is in the ACTION property. That is just how forms
work. If you don't go to the ACTION's url then the data is not
transmitted. Now as I said you can give the appearance that the form is
static by posting to yourself.

//quagmire.php
<?php
if( isset($_POST['times']) ){
$visits=$_POST['times'];
$visits++;
$msg="Welcome back, you have visited $visits time";
}
else {
$visits=0;
$msg="Welcome to the Quagmire, press the Submit button";
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Quagmire</title>
</head>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"
enctype="application/x-www-form-urlencoded">
<p><?php echo $msg; ?></p>
<div>
<input name="times" type="hidden" value="<?php echo $visits; ?>">
<input type="submit">
</div>
</form>
</body>
</html>
 
V

Vince Morgan

Jonathan N. Little said:
Look Vince if you want a form to actually submit the data the URL will
change to whatever is in the ACTION property. That is just how forms
work. If you don't go to the ACTION's url then the data is not
transmitted. Now as I said you can give the appearance that the form is
static by posting to yourself.

//quagmire.php
<?php
if( isset($_POST['times']) ){
$visits=$_POST['times'];
$visits++;
$msg="Welcome back, you have visited $visits time";
}
else {
$visits=0;
$msg="Welcome to the Quagmire, press the Submit button";
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Quagmire</title>
</head>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"
enctype="application/x-www-form-urlencoded">
<p><?php echo $msg; ?></p>
<div>
<input name="times" type="hidden" value="<?php echo $visits; ?>">
<input type="submit">
</div>
</form>
</body>
</html>


--
Take care,

Jonathan
-------------------

I'm sorry I was more than a little slow getting the idea here. Your example
behaves exactly as required and I apologize for not getting the picture
earlier. Thank you very much indeed for the patience and taking the time to
provide an example Jonathan.
Highest regards,
Vince Morgan.
 
V

Vince Morgan

The quality of the help here has been exceptional and I'm very grateful.
Thank you all very much.

Vince Morgan
 
J

Jonathan N. Little

Vince said:
I'm sorry I was more than a little slow getting the idea here. Your example
behaves exactly as required and I apologize for not getting the picture
earlier. Thank you very much indeed for the patience and taking the time to
provide an example Jonathan.

No need to apologize, we all were beginners, I just wanted you to
understand the process. You can post to the same script for multipage
forms with a passed parameter to keep track of the 'step' your on, or
cycle to add info until a condition and met and the server-side can
conclude by changing the generated form's ACTION.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top