Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-10-2008, 12:47 PM   PM User | #1
AdamC86
New to the CF scene

 
Join Date: Mar 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
AdamC86 is an unknown quantity at this point
PHP form & calculations

Hi all,

I'm creating a form for a website and I need to have a calculation performed on one of the form inputs (a numerical value).

Basically, the user will enter a value into the field (x) in the form, and submit it as usual. This information will then all be processed and emailed to the site owner, and take the user to a second page which will say "Please wait... Calculating your value" or something similar. It'll then go to a third page which will display a value based on a calculation (x * 0.82) and ask the user to confirm the offer.

To give you a better idea of the process, http://www.networkpropertybuyers.co.uk/?action=enquiry is pretty much the sort of thing we're looking at.

Is anyone able to help or point me in the right direction?
AdamC86 is offline   Reply With Quote
Old 03-10-2008, 01:13 PM   PM User | #2
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,042
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
What is the purpose of the "please wait" page ...
the calculation is instant and no waiting is required.

You can pass variables from one form to another using <input type="hidden" ... >
or you can use PHP session variables, or cookies.
mlseim is offline   Reply With Quote
Old 03-10-2008, 02:19 PM   PM User | #3
AdamC86
New to the CF scene

 
Join Date: Mar 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
AdamC86 is an unknown quantity at this point
Quote:
Originally Posted by mlseim View Post
What is the purpose of the "please wait" page ...
the calculation is instant and no waiting is required.

You can pass variables from one form to another using <input type="hidden" ... >
or you can use PHP session variables, or cookies.
Thanks for your reply. My knowledge of PHP and variables is pretty stunted - could you expand on your example please?

Also, the please wait page is used to give the impression that it's searching through a database of similar properties and doing a lot of calculations - it's all faff, but what the client wants... :-)
AdamC86 is offline   Reply With Quote
Old 03-10-2008, 08:03 PM   PM User | #4
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,042
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
A really simple example of passing using POST method and hidden form variables:

The first form:
PHP Code:
<form action="secondform.php" method="post">
Name: <input type="text" name="user" value=""><br>
Email: <input type="text" name="email" value=""><br>
<
input type="submit" name="submit" value="submit"
secondform.php
PHP Code:
<?php
$name
=$_POST['name'];
$email=$_POST['email'];
?>

<form action="thirdform.php" method="post">
<input type="hidden" name="user" value="<?=$name?>"><br>
<input type="hidden" name="email" value="<?=$email?>"><br>
Phone: <input type="text" name="phone" value=""><br>
Option: <input type="text" name="option" value=""><br>
<input type="submit" name="submit" value="submit">
thirdform.php
PHP Code:
<?php
$name
=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$option=$_POST['option'];

Echo
"
Here are your results:
$name
$email
$phone
$option
"
;
?>
=================

The "Wait" page .... <sigh>
Tell your client that nobody will be impressed with that.

Maybe you can do a javascript thing with an animated .gif?

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

The other option with using Sessions or Cookies ... takes too much time to explain.
Search Google for a "PHP Cookie shopping cart script" ... it's sort of the same thing.
mlseim is offline   Reply With Quote
Old 03-10-2008, 08:11 PM   PM User | #5
Andrew Johnson
Banned

 
Join Date: Feb 2008
Location: Winnipeg, Canada
Posts: 396
Thanks: 0
Thanked 29 Times in 29 Posts
Andrew Johnson can only hope to improve
Why use PHP at all? Why not just use Javascript and if you need to change the page (which I doubt) just use AJAX/DHTML
Andrew Johnson is offline   Reply With Quote
Old 03-11-2008, 01:48 AM   PM User | #6
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
Quote:
Originally Posted by mlseim View Post
=================

The "Wait" page .... <sigh>
Tell your client that nobody will be impressed with that.

Maybe you can do a javascript thing with an animated .gif?

=================
why not php?,

PHP Code:
$message = array("please wait, we work hard here...",
                          
"...we are allready finish...",
                          
"...we are closer...",
                          
"sorry, we fail, but don\'t warry, nothing can stop us, will start again...");

if(isset(
$_GET['msg'])){
   
$msg $_GET['msg'];
   if(
$msg 3){
      
$msg++;
   }else{
      
$msg 0;
   }
}else{
   
$msg 0;
}
print 
"<p>".$message[$msg]."</p>";
print 
'<a href="$_SERVER['PHP_SELF]?msg=$msg">click here next week</s>"
not tested, probably don't work,

Edit:
Changelog:
1.0.0 - fix some bug and improve functionality

Todo:
- to add a "you are ugly" message


best regards

Last edited by oesxyl; 03-11-2008 at 02:06 AM..
oesxyl is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:55 AM.


Advertisement
Log in to turn off these ads.