Jump to content

Help with webform to email script


ifonlyiwerecool9

Recommended Posts

I'm sure this has been covered many times, but I can't get my webform to send an e-mail. I've looked at several people's scripts, and mine is so similar I can't figure out why its not working. My partner has written another script from the same host, which works, so there isn't an issue with the host setup.

 

When I use the script, it just brings up my error page, meaning it was unable to send the email.

 

<?php

 

/* Subject and Email Variables */

 

$emailSubject = 'WorkShop Schedule Request';

    $webMaster = '[email protected]';

   

/* Gathering Data Variables */

 

$nameField = $_POST['your_name'];

$phoneField = $_POST['phone_number'];

$emailField = $_POST['email'];

$cnameField = $_POST['confirm_name'];

$cphoneField = $_POST['confirm_phone'];

$cemailField = $_POST['confirm_email'];

$snameField = $_POST['school_name'];

$saddressField = $_POST['school_address'];

$sdistrictField = $_POST['school_district'];

$gradepkField = $_POST['grade_pk'];

$gradekField = $_POST['grade_k'];

$grade1Field = $_POST['grade_1'];

$grade2Field = $_POST['grade_2'];

$grade3Field = $_POST['grade_3'];

$grade4Field = $_POST['grade_4'];

$grade5Field = $_POST['grade_5'];

$grade6Field = $_POST['grade_6'];

$grade7Field = $_POST['grade_7'];

$grade8Field = $_POST['grade_8'];

$grade9Field = $_POST['grade_9'];

$grade10Field = $_POST['grade_10'];

$grade11Field = $_POST['grade_11'];

$grade12Field = $_POST['grade_12'];

$wtitleField = $_POST['workshop_title'];

$wsubjectField = $_POST['workshop_subject'];

$wprefField = $_POST['workshop_pref'];

$wtimesField = $_POST['workshop_times'];

$tnameField = $_POST['workshop_teachername'];

$wclassField = $_POST['workshop_classroom'];

$nstudentsField = $_POST['workshop_studentnumber'];

$dapprovalField = $_POST['radio1'];

$anameField = $_POST['approval_name'];

$aemailField = $_POST['approval_email'];

$papprovalField = $_POST['radio'];

$pnameField = $_POST['approval2_name'];

$pemailField = $_POST['approval2_email'];

$pphoneField = $_POST['approval2_phone'];

 

$body = <<<EOD

<br><hr><br>

Name: $name <br>

Email: $email <br>

Phone Number: $phone <br>

<br>

Confirmation Name: $cname <br>

Confirmation Phone Number: $cphone <br>

Confirmation Email: $cemail <br>

<br>

School Name: $sname <br>

School Address: $saddress <br>

School District: $sdistrict <br>

$grade_pk $grade_k $grade_1 $grade_2 $grade_3 $grade_4 $grade_5 $grade_6 $grade_7 $grade_8 $grade_9 $grade_10 $grade_11 $grade_12 <br>

Workshop Title: $wtitle <br>

Workshop Subject: $wsubject <br>

Preferred Dates: $wpref <br>

Preffered Times: $wtimes <br>

Teacher Name: $tname <br>

Classroom: $wclass <br>

Number of Students: $nstudents <br>

$dapproval <br>

Name of Approval Person: $aname <br>

Email of Approval Person: $aemail <br>

$papproval <br>

Name of Principal: $pname <br>

Email of Principal: $pemail <br>

Phone Number of Principal: $pphone <br>

EOD;

 

$headers = "From: $email\r\n";

$headers .= "Content-type: text/html\r\n";

$success = mail($webmaster, $emailSubject, $body, $headers);

 

/* Results Rendered as HTML */

$theResults = <<<EOD

<html>

<head>

<title>Schmahl Science Workshop Request Form Submitted!</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">

<!--

body {

background-color: #f1f1f1;

font-family: Verdana, Arial, Helvetica, sans-serif;

font-size: 12px;

font-style: normal;

line-height: normal;

font-weight: normal;

color: #666666;

text-decoration: none;

}

-->

</style>

</head>

 

<div>

  <div align="left">Thank you for the request. We will get back to you as soon as we can!</div>

</div>

</body>

</html>

EOD;

$otherResults = <<<EOD

<html>

<head>

<title>Workshop Request Form Submitted!</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">

<!--

body {

background-color: #f1f1f1;

font-family: Verdana, Arial, Helvetica, sans-serif;

font-size: 12px;

font-style: normal;

line-height: normal;

font-weight: normal;

color: #666666;

text-decoration: none;

}

-->

</style>

</head>

 

<div>

  <div align="left">Im sorry, but your e-mail couldnt be processed.</div>

</div>

</body>

</html>

EOD;

if ($success == true)

echo "$theResults";

else

echo "$otherResults";

 

?>

Link to comment
https://forums.phpfreaks.com/topic/187167-help-with-webform-to-email-script/
Share on other sites

Thank you, I can't believe I didn't see that.

 

However, while it is now sending me an e-mail like it should, it doesn't seem like it is taking in any of the information from the form, even though the form was filled out completely. Are there any normal solutions or things I would have missed where it would be doing this?

 

Here is an example e-mail I've received now:

 

Name:

Email:

Phone Number:

 

Confirmation Name:

Confirmation Phone Number:

Confirmation Email:

 

School Name:

School Address:

School District:

 

Workshop Title:

Workshop Subject:

Preferred Dates:

Preffered Times:

Teacher Name:

Classroom:

Number of Students:

 

Name of Approval Person:

Email of Approval Person:

 

Name of Principal:

Email of Principal:

Phone Number of Principal:

 

I appreciate the help, I am fairly new to php and it is my first time dealing with web forms.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.