Hope someone can help me here, I'm a bit of a beginner (understatement) with php and I'm having a real problem with something that ought to be fairly simple from what I've read.
I have a form on a basic html page ( call it page1.html ) which I am wanting to get to submit three fields to the next page ( page2.html ) : I want two of the fields to echo in another part of the page2.html ( I can do that bit! ) but I also want those two values (and the third value) to be picked up and inserted into a mySQL database upon submission of the next form, which is also on page2.html. This form contains an additional 12 fields which I want written to the database, along with the values from page1.html
Ideally, I would also like to be able to send 4 of the second lot of 12 fields to another webpage via URL.
Can this be done? If so, can anyone suggest a method of doing this, or tell me where to look?
Yours, really really stuck and pulling my hair out now,
</tr> THIS IS THE BIT I'M PRETTY SURE IS COMPLETELY AND UTTERLY WRONG <input type="hidden" value="quantity">
<input type="hidden" value="ROL"> </form>
So - I have no idea how to get the information - all the fields - from this page into my database, and how to send a further 4 values - namely : 'fname', 'address_1', 'zip' and 'quantity' - into the URL and over to another page.
I hope this makes sense. If not I may well just throw the PC out of the window.
OK made a bit of progress but still have a problem :
this is the modified code from the bottom of the second form - (again edited and some values changed)
<input type="hidden" value="quantity">
<input type="hidden" value="<?php print $compcode; ?>">
<?$dbh=mysql_connect ("localhost", "server_username", "password") or die ('Cannot connect to MySQL database because: ' . mysql_error());
mysql_query ("INSERT INTO dbname (quantity, compcode, fname, address_1, address_1a, address_2, county, country, zip, submit_by, PrPhone, SecPhone) VALUES ('$quantity','$compcode','$fname','$address_1','$address_1a','$address_2','$county','$country','$zip ','$submit_by','$PrPhone','$SecPhone')");
Connect to db fine.
However - only inserts the fields from the first form - 'quantity' and 'compcode' - none of the fields from the second form go in.
Although - MrShed, I changed some of your SQL code because I kept getting a SQL error : so is the problem in the SQL query part that I have changed? yours didnt seem to work but perhaps I am doing something else wrong (this is more than likely btw)
Thanks for all your help, I am a newbie at most of this.
PS How do I get some of the values from this second form into the url for submission to another site? Sorry to sound like a dumbass. I am.
The second pages variables will not be going in because you won't have submitted the form yet if that code is in the second page. You need to have the insert code in a third page. And my MySQL query could well have been wrong....yours looks ok imo.
Beauty is in the eye of the beer-holder
Have now created a third page with the mySQL INSERT command on it - now all the data from page two goes in, but the first two fields from page one - 'compcode' and 'quantity' must be getting lost somewhere.
This is the code I've got in the bottom of the SECOND form, which I think brings the values over the the FIRST form (as you guys suggested yesterday - thanks)
ahhh think ive spotted the problem. have you got those first two lines inside php tags? or outside of them? if they are not in php tags, quantity and compcode will be getting parsed as that text, not as the variable contents(and they should be $quantity and $compcode). Oh and if you haven't named them is it possible to access them? I don't know but I wouldn't have thought so. So something like this: