Jonathan
12-18-2003, 02:35 AM
I can't seem to find what is wrong with this script... I want it to enter it into a database and mail to the pastor. You can see a working one here: crosspoint.org/delete/registration.php but I am not sure if that will help much. Here:
<?php
function connect($db_host,$db_username,$db_password,$db_name){
mysql_pconnect($db_host,$db_username,$db_password) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());
}
function process_registration(){
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$address = $_POST['address'];
$phone = $_POST['phone'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$ip = $_SERVER['REMOTE_ADDR'];
if(($fname) && ($lname) && ($email) && ($phone) && ($city) && ($state) && ($zip)){
# E-mail
if(!eregi("^[0-9a-zA-Z\.\-\_]+@+[0-9a-zA-Z\.\-\_]+\.+[a-z0-9A-Z\.\_\-]+$", $email)){
echo "Invalid e-mail.";
exit();
}
# Phone number
if(!preg_match("/\d{3}\w?\d{3}\w?\d{4}\w?(\wext\w\d+/i", $phone) || ($phone == "000 000 0000")){
echo "Invalid phone number.";
exit();
}
} else {
echo "Please enter all of the information. (address not included)";
exit();
}
connect("localhost","usr","pass","crosspoint_members");
$selection = mysql_query("select * from registration where ip_address='$ip' or phone_number='$phone' or address='$address' or first_name='$fname' or last_name='$lname' or email_address='$email'") or die(mysql_error());
$number_rows = mysql_num_rows($selection);
if ($number_rows >=1){
echo "Our database contains some/all of the information given. If this is not true, then please contact the webmaster.";
exit();
} else {
$fname = addslashes($fname);
$lname = addslashes($lname);
$email = addslashes($email);
$address = addslashes($address);
$phone = addslashes($phone);
$city = addslashes($city);
$state = addslashes($state);
$zip = addslashes($zip);
$date = date('F d, Y');
$insert = mysql_query("insert into registration values(mysql_insert_id(),$fname,$lname,$email,$address,$phone,$city,$state,$zip,$ip,$date)") or die(mysql_error());
if($insert){
$message = "Registration info below:\n"
."First Name: $fname \n"
."Last Name: $lname \n"
."Email: $email \n"
."Addres: $address \n"
."Phone #: $phone \n"
."City: $city \n"
."State: $state \n"
."Zip Code: $zip \n";
$email = @mail("dvaughan@crosspoint.org","Registration",$message);
if ($email){
echo "E-mail sent to the pastor. Thank you for signing up for Crosspoint Community Church.";
} else {
@mail("webmaster@crosspoint.org","Error (Registration Form)","An error has occured... Please check coding for the registration php page.");
echo "An e-mail was sent to the webmaster because an error has occured in adding information. No private information was sent.";
}
}
?>
I have the process_registration() function on the form. it is a action="<? echo $_SERVER['PHP_SELF']; ?>" ... any help?
Thanks in advance...
<?php
function connect($db_host,$db_username,$db_password,$db_name){
mysql_pconnect($db_host,$db_username,$db_password) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());
}
function process_registration(){
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$address = $_POST['address'];
$phone = $_POST['phone'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$ip = $_SERVER['REMOTE_ADDR'];
if(($fname) && ($lname) && ($email) && ($phone) && ($city) && ($state) && ($zip)){
if(!eregi("^[0-9a-zA-Z\.\-\_]+@+[0-9a-zA-Z\.\-\_]+\.+[a-z0-9A-Z\.\_\-]+$", $email)){
echo "Invalid e-mail.";
exit();
}
# Phone number
if(!preg_match("/\d{3}\w?\d{3}\w?\d{4}\w?(\wext\w\d+/i", $phone) || ($phone == "000 000 0000")){
echo "Invalid phone number.";
exit();
}
} else {
echo "Please enter all of the information. (address not included)";
exit();
}
connect("localhost","usr","pass","crosspoint_members");
$selection = mysql_query("select * from registration where ip_address='$ip' or phone_number='$phone' or address='$address' or first_name='$fname' or last_name='$lname' or email_address='$email'") or die(mysql_error());
$number_rows = mysql_num_rows($selection);
if ($number_rows >=1){
echo "Our database contains some/all of the information given. If this is not true, then please contact the webmaster.";
exit();
} else {
$fname = addslashes($fname);
$lname = addslashes($lname);
$email = addslashes($email);
$address = addslashes($address);
$phone = addslashes($phone);
$city = addslashes($city);
$state = addslashes($state);
$zip = addslashes($zip);
$date = date('F d, Y');
$insert = mysql_query("insert into registration values(mysql_insert_id(),$fname,$lname,$email,$address,$phone,$city,$state,$zip,$ip,$date)") or die(mysql_error());
if($insert){
$message = "Registration info below:\n"
."First Name: $fname \n"
."Last Name: $lname \n"
."Email: $email \n"
."Addres: $address \n"
."Phone #: $phone \n"
."City: $city \n"
."State: $state \n"
."Zip Code: $zip \n";
$email = @mail("dvaughan@crosspoint.org","Registration",$message);
if ($email){
echo "E-mail sent to the pastor. Thank you for signing up for Crosspoint Community Church.";
} else {
@mail("webmaster@crosspoint.org","Error (Registration Form)","An error has occured... Please check coding for the registration php page.");
echo "An e-mail was sent to the webmaster because an error has occured in adding information. No private information was sent.";
}
}
?>
I have the process_registration() function on the form. it is a action="<? echo $_SERVER['PHP_SELF']; ?>" ... any help?
Thanks in advance...