×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

enter two submits from a form

enter two submits from a form

enter two submits from a form

(OP)
Hi

I'm trying to build a insert statement, on the first call from the form this information is filled is

CODE

$sqlstatement = "INSERT INTO auctions (user,title,subtitle,starts,description,pict_url,category,secondcat,minimum_bid,shipping_cost,shipping_cost_additional,reserve_price,buy_now,auction_type,duration,increment,shipping,payment,international,ends,current_bid,closed,photo_uploaded,quantity,suspended,relist,relisted,num_bids,sold,shipping_terms,bn_only,bold,highlighted,featured,current_fee,tax,taxinc,asking,item_condition,item_manufacturer,item_model,item_colour,item_year) VALUES (".$_SESSION['WEBID_LOGGED_IN'].",'".$titlestr."','','" . time(). "','".$descstr."','".$image_name."',278,0,".$pricestr.",".$shippingcoststr.",0,0,".$pricestr.",'1',30,0,'1','paypal','0','".$endtime."',0,'0','0',1,0,2,0,0,'n','','".$binY."','n','n','n',0,'n','y','','".$condstr."','n/a','n/a','n/a','n/a ')"; 

the second call is for a shipping cost then replace shipping_cost variable with the users input, what would be the best way to go about this? build a query on the address bar or session vars?

RE: enter two submits from a form

If you absolutely need to do it in 2 steps, use Sessions. store the values from the first form in a session, and build the entire query once you have collected all the information you need for it.

The query-string in the address bar can be tampered with before the final build, your session variables cannot.



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech

RE: enter two submits from a form

(OP)
Yep, thanks vacunita, what if I want to be presented with:

1. entry box for data, then once that was submitted another box asking for 1 more piece of data, whats the best way with php, still getting to grips with the code

RE: enter two submits from a form

Quote:

whats the best way with php,

You can't "wait" using PHP, all you can do with PHP is present another 'page' requesting new input data.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: enter two submits from a form

(OP)
what about form to another form and the last value hidden has its value in the second form?

RE: enter two submits from a form

As I said, use sessions. and present another page to collect the rest of the data. Your second data collecting page can also serve to store data form the first one in the session. You can later retrieve it in the final process.

Very simply:

CODE --> form1.php

<form action="form2.php" method="post">
<input type="text" name="firstvalue">
<input type="submit" name="send1" value="Go to Second Form ">
</form> 


CODE --> form2.php

<?php
if(isset($_POST['send']))
{
session_start();

/* store data in session */ 
$_SESSION['valuefromfirstform'] = $_POST['firstvaue'];

session_write_close();

}

else
{
 /* redirect back to first form if value not present. */
}

?>
<!-- display second form -->

<form action="finalprocess.php" method="post">
<input type="text" name="secondvalue">
<input type="submit" name="send2" value="Go To Final Process">
</form> 



CODE --> finalprocess.php

<?php
if(isset($_POST['send2'))
{
session_start();

/*retrieve variable stored in session*/

$firstvalue = $_SESSION['valuefromfirstform'];

$secondvalue = $_POST['secondvalue'];

session_write_close();
/* do whatever with both values */
...
}
?> 


Yes, you can use a hidden form element in the second form to store whatever you got from the first one too, but again that can be messed with client side. You are better served by using sessions.

You could even do this in a single file, if you also conditionalize which form is shown each time, you would still need sessions though.



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech

RE: enter two submits from a form

(OP)
Cool

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close