Hi Everyone!
I'm hoping someone here can help me. I have a 5 page form with roughly 175
fields/checkboxes that I'm trying to get inserted into a mysql database.
My deadline on this whole project was only 3 days so I had to figure out a quick method of doing things. Rather than using sessions and/or standard php arrays I found a snippet of code that takes all $_POST data from a previous page and creates hidden fields in the next page. That works just fine for this project.
here's that bit of code:
<?php foreach ($_POST as $key => $val) {
echo '<input type="hidden" name="' . $key . '" value="'
. htmlentities($val, ENT_QUOTES) . '" />' . "\r\n";
}
?>
Ok, so this as I said is spread out through pages 2 through 5 and each page posts to the next page. Then page 5 posts to process.php which is supposed to take all the previous fields and insert into a database. But I can't get it to work. here's what I have in process.php
<?php include("../Connections/wtrcapp.php"); ?>
<?php foreach ($_POST as $key => $val) {
echo '<input type="hidden" name="' . $key . '" value="'
. htmlentities($val, ENT_QUOTES) . '" />' . "\r\n";
}
foreach($key as $val) {
$insert="INSERT INTO westoco6_app (".implode(",", array_keys($key)).") VALUES ('".implode("','", array_values($val))."')";
}
mysql_query($insert) OR die(mysql_error())
?>
Now I don't know that I'm even close to the mark on this but i think I am...most of my errors originate from line 6, the second foreach statement.
The error I'm getting with the above code is:
Warning: Invalid argument supplied for foreach() in /home/westoco6/public_html/app/process.php on line 6
Query was empty
If anyone can give me a clue as to what I'm doing wrong here or point me in a better direction I'd be very appreciative. My deadline ends in the morning.
Thanks much for your time,
Michael Smith