Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

enter two submits from a form 1

Status
Not open for further replies.

someoneneedshelps

Technical User
Mar 3, 2016
75
0
0
GB
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?
 
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
 
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
 
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
 
what about form to another form and the last value hidden has its value in the second 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:
<form action="form2.php" method="post">
<input type="text" name="firstvalue">
<input type="submit" name="send1" value="Go to Second Form ">
</form>

Code:
<?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:
<?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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top