I've got a simple project going live tomorrow and I can't figure out what is going wrong. I've created a simple, 6 field form for people to fill out that inserts the data into a mysql database table. When the information is submitted, the sql statement is called and after that, I get an email alerting me of the submission. The wierd thing is that I get no errors when I test it, and I receive a confirmation email, but there are no records inserted into the database table. Any idea what would be causing it? I will be on here all night looking for an answer.
Here is my process page behind the form:
<?php
include("global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','firstname');
pt_register('POST','birthdate');
pt_register('POST','dinnergroup');
pt_register('POST','city');
pt_register('POST','emailaddress');
pt_register('POST','information');
$information=preg_replace("/(\015\012)|(\015)|(\012)/"," <br />", $information);
if($firstname=="" || $birthdate=="" || $dinnergroup=="" || $city=="" || $emailaddress=="" ){
$errors=1;
$error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
}
if(!eregi("[a-z0-9]+([_\.-][a-z0-9]+)" ."@"."([a-z0-9]+([.-][a-z0-9]+))+"."\.[a-z]{2,}"."$",$emailaddress)){
$error.="<li>Invalid email address entered";
$errors=1;
}
if($errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="firstname: ".$firstname."
birthdate: ".$birthdate."
dinnergroup: ".$dinnergroup."
city: ".$city."
emailaddress: ".$emailaddress."
information: ".$information."
";
$message = stripslashes($message);
$link = mysql_connect("localhost","*","");
mysql_select_db("",$link);
mysql_query($query);
$query="insert into signup message(firstname,birthdate,dinnergroup,city,emailaddress,information) values('".$firstname."', '".$birthdate."', '".$dinnergroup."', '".$city."', '".$emailaddress."', '".$information."')";
header("Refresh: 0;url=../billing.html");
mail("","",$message,"*");
}
?>
And here is the global.inc.php code:
<?php
function pt_register()
{
$num_args = func_num_args();
$vars = array();
if ($num_args >= 2) {
$method = strtoupper(func_get_arg(0));
if (($method != 'SESSION') && ($method != 'GET') && ($method != 'POST') && ($method != 'SERVER') && ($method != 'COOKIE') && ($method != 'ENV')) {
die('The first argument of pt_register must be one of the following: GET, POST, SESSION, SERVER, COOKIE, or ENV');
}
$varname = "HTTP_{$method}_VARS";
global ${$varname};
for ($i = 1; $i < $num_args; $i++) {
$parameter = func_get_arg($i);
if (isset(${$varname}[$parameter])) {
global $$parameter;
$$parameter = ${$varname}[$parameter];
}
}
} else {
die('You must specify at least two arguments');
}
}
?>