My php form doesn't throw and error, but not working

Can someone look this over and help find out what is going on.

This is a simple form for a golf tournament. When I tried this yesterday, and uploaded it to my server, I could go through a very basic form, and send email from the server. The page would also redirect to the text at the bottom of the email.php page That is what I wanted.

I have added the last 3 parts of the form. card, number and expiry, and now the form doesn’t work. I had a few syntax errors, and figured the, out…missing letters, etc, and now I get no errors.

All I get is a a blank white screen. No errors, and no emails.

I really need to get this fixed up over the weekend…Please can some one help.

[code]<?php

if(isset($_POST[‘email’])) {

// EDIT THE 2 LINES BELOW AS REQUIRED

$email_to = "xxx.xxxx.ca";
$email_subject = "New Golf registry";

 

 

function died($error) {

    // your error code can go here

    echo "We are very sorry, but there were error(s) found with the form you submitted. ";

    echo "These errors appear below.<br /><br />";

    echo $error."<br /><br />";

    echo "Please go back and fix these errors.<br /><br />";

    die();

}

 

// validation expected data exists

if(!isset($_POST['name']) ||

    !isset($_POST['address']) ||

    !isset($_POST['email']) ||

    !isset($_POST['phone']) ||

    !isset($_POST['homeClub']) ||
    
    !isset($_POST['handicap']) ||
    
    !isset($_POST['card']) ||
    
    !isset($_POST['number']) ||
    
    !isset($_POST['expiry']) ) {

    died('We are sorry, but there appears to be a problem with the form you submitted.');       

}

 

$name = $_POST['name']; // required

$address = $_POST['address']; // required

$phone = $_POST['phone']; // required

$email = $_POST['email']; //  required

$homeClub = $_POST['homeClub']; // required

$handicap = $_POST['handicap']; // not required

$card = $_POST['card']; // required

$number = $_POST['number']; // required

$expiry = $_POST['expiry']; // required
 

$error_message = "";

$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';

if(!preg_match($email_exp,$email_from)) {

$error_message .= 'The Email Address you entered does not appear to be valid.<br />';

}

$name_exp = "/^[A-Za-z .'-]+$/";

if(!preg_match($name_exp,$name)) {

$error_message .= 'The Name you entered does not appear to be valid.<br />';

}

$address_exp = '/^[A-Za-z0-9._%-]+$/';

if(!preg_match($address_exp,$address)) {

$error_message .= 'The address you entered does not appear to be valid.<br />';

}
$phone_exp = ‘/^[0-9._%.-]+$/’;
if(!preg_match($phone_exp,$phone)) {

$error_message .= 'The phone number you entered does not appear to be valid.<br />';

}

$homeClub_exp = '/^[A-Za-z0-9._%-]+$/';
if(!preg_match($homeClub_exp,$homeClub)) {

$error_message .= 'The Home Club you entered does not appear to be valid.<br />';

}
$handicap_exp = ‘/^[0-9-+]+$/’;
if(!preg_match($handicap_exp,$handicap)) {

$error_message .= 'The handicap you entered does not appear to be valid.<br />';

}

 $card_exp = "/^[A-Za-z .'-]+$/";

if(!preg_match($card_exp,$card)) {

$error_message .= 'The Name you entered for your credit card does not appear to be valid.<br />';

}

 $number_exp = "/^[0-9 .'-]+$/";

if(!preg_match($number_exp,$number)) {

$error_message .= 'The Credit Card information you entered does not appear to be valid.<br />';

}

 $expiry_exp = "/^[A-Za-z0-9 .'-]+$/";

if(!preg_match($expiry_exp,$expiry)) {

$error_message .= 'The Expiry Date on your credit card that you entered does not appear to be valid.<br />';

}

$email_message = "Form details below.\n\n";

 

function clean_string($string) {

  $bad = array("content-type","bcc:","to:","cc:","href");

  return str_replace($bad,"",$string);

}

 

$email_message .= "Name : ".clean_string($name)."\n";

$email_message .= "Address: ".clean_string($address)."\n";

$email_message .= "Email: ".clean_string($email). "\n";

$email_message .= "Number: ".clean_string($phone)."\n";

$email_message .= "Home Club: ".clean_string($homeClub)."\n";

$email_message .= "Handicap: ".clean_string($handicap)."\n";
 
$email_message .= "Credit Card: ".clean_string($card)."\n";

$email_message .= "Number: ".clean_string($number)."\n";

$email_message .= "Expiry".clean_string($expiry)."\n";

// create email headers

$headers = 'From: '.$email."\r\n".

$headers .=“CC: Mail1 [email protected]”;
$headers .=", Mail2 [email protected]";
'Reply-To: '.$email."\r\n" .

‘X-Mailer: PHP/’ . phpversion();

@mail($email_to, $email_subject, $email_message, $headers);

?>

Thank you for contacting us. Your registation and payment has been processed, and we will be in touch with you very soon.

<?php } ?>

[/code]

And here is the for from the html page:

[code]<form action=“email.php” method=“post”

Golf Registration

Name:


Address:



Phone:
E-mail:

Home Club:
<input type=“text” align=“right"name=“Home Club " value=”” size=“40”>Handicap:


REGISTRATION FEE PAYMENT OF $150 MUST BE MADE ONLINE IF USING THIS ENTRY FORM.

EXTRA DINNER TICKETS $50.00 EACH x
=



I would like to make an additional donation to the Foundation: $<input type=“text” Name=“Additional Donation " + “&nspb” value=”"size=“20”>

PREFERRED SHOTGUN START:(PLEASE CHECK ONE)
8AM OR 1PM

Online Payment Information


Name(As it appears on your card):

Number:
Expiry:

Your payment will be processed by hand until further notice.

To ensure REGISTRATION, please submit before August 23, 2014 For more information: xxx.xxx.xxxx








 
[/code]

Any help is greatly appreciated.

First, I would suggest not having the person registering give his or her credit number out over an unsecured registration form. If the process is going to be done by hand then have the person registering leave a call back number and do it over the phone or send it in via snail mail. If you insist in doing online transactions use a credit processing company (CCBILL or even Paypal). They’ll give you the script when you sign up with them.

we are actually setting up with Paypal.

The form will still not send an email or redirect to the thank you message.

If I remove the card/ number and expiry, it still just goes to a white page.

Any ideas on getting that working?

Let me clarify, I will be adding the code for Paypal payment this weekend, I just wanted to make sure the page would work with the rest of my registration page.

I was goofing around with the following attachment, I was bored. ;D If you want I can finish it up for you and even add some neat bells & whistles ( bare minimum get it working for you) or I can help you out even you want to go it on you own?

I get you started, put this before for the DOCTYPE
[php]<?php
/* I use a hidden form for the submit button can be flaky at times */
if (isset($_POST[‘action’]) && $_POST[‘action’] == ‘submitForm’) {

}

?>[/php]


golfRegistration.zip (1.27 KB)

the submit button can be flaky at times

I have never experienced such a thing. Could you elaborate?

In some cases in older versions of IE the input submit button might not fire, this just ensures that it does. Plus you can have the value anything you want and not have look weird on the form. :wink:

I never use IE except for checking cross browser compatibility. I hate it, just hate it I tell ya.

Sponsor our Newsletter | Privacy Policy | Terms of Service