<?php
/*
If I change the action of the form to echo self, it inserts in the database
but wont submit to http://some.other.server.
Note that this is an abbreviated form, the real form has about 30 fields, tons
of select option menus, radios, checkboxes and like 1000 lines of html in it.
I'm just using the below for example
*/
?>
<form name="form1" method="post" action="http://some.other.server/cgi-bin/formwork2.cgi">
<table width="350" border="1">
<tr>
<td>first</td>
<td>
<input type="text" name="fname">
</td>
</tr>
<tr>
<td>last</td>
<td>
<input type="text" name="lname">
</td>
</tr>
<tr>
<td>city</td>
<td>
<input type="text" name="city">
</td>
</tr>
<tr>
<td>state</td>
<td>
<input type="text" name="state">
</td>
</tr>
<tr>
<td>email</td>
<td>
<input type="text" name="email">
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" name="submit" value="Submit">
<input type="reset" name="reset" value="Reset">
</td>
</tr>
</table>
</form>
<?php
/
If I submit to self, then the header: Location thing breaks.
If I submit to some.other.server, it won't capture the subset of data that
I need.
/
if($submit){
$db = mysql_connect("localhost", "user", "pass");
mysql_select_db("mydb", $db);
$address .= " ".$apartment_suite;
//pretend all the fields below exist in the form above. 🙂
$query = "insert into contact (salutation, fname, lname, email, address, city,
state, country, zipcode, dob, product, handed, entryPoint) values
('$title', '$first_name', '$last_name', '$email', '$address', '$city', '$state',
'$country', '$zipcode', '$dob', '$product', '$handed', '$entryPoint') ";
mysql_query($query, $db)or die("bad query");
//echo "nice query"; //debug
/*
These are only a few of the parameters of the real form. Luckily I decided to test it
before I typed all that crap!
Is it even necessary to rawurlencode($field) as below? If I know the data is ok -- like
from a select (<option value='1'>) -- can I just send it without url encoding it?
*/
$params = "formid=rawurlencode($formid)&now2000=rawurlencode($now2000)&";
$params .= "req-nexturl=http://www.company.com/clubhouse/register_thankyou.html&";
$params .= "title=rawurlencode($title)&wdopt=rawurlencode($wdopt)&expopt=rawurlencode($wdopt)&";
$params .= "what=rawurlencode($whatpur)&shaft=rawurlencode($shaft)&playgen=rawurlencode($playgen)&";
$params .= "whopur=rawurlencode($whopur)&marital_status=rawurlencode($marital_statues)&";
$params .= "influence=rawurlencode($influence)&seenads=rawurlencode($seenads)&" ;
$params .= "magazine=rawurlencode($magazine)&prevown=rawurlencode($prevown)&";
$params .= "sixmo_activities=rawurlencode($sixmo_activities)";
//echo $params; //debug
header ("Location: http://some.other.server/cgi-bin/formwork2.cgi?$params");
exit;
}
?>