Ja coden bliver afviklet fordi når jeg echoer den, så står der det som jeg havde forventet i mailen.
Jeg får ikke nogen fejlmeddelelser.
Den skriver også successtexten som om det virker.
Oven over mail coden indsætter den oplysningerne i en database, og det virker. Så koden bliver afviklet, det er kun sende funktionen.
Variablerne bliver defineret i toppen af siden.
Her er alt min kode:
- <?php
-
- $name = mysql_escape_string($_POST['name']);
- $birth = mysql_escape_string($_POST['birth']);
- $gender = mysql_escape_string($_POST['gender']);
- $mail = mysql_escape_string($_POST['mail']);
- $mobile = mysql_escape_string($_POST['mobile']);
- $address = mysql_escape_string($_POST['address']);
- $postal = mysql_escape_string($_POST['postal']);
- $city = mysql_escape_string($_POST['city']);
- $country = mysql_escape_string($_POST['country']);
- $packagedeal = mysql_escape_string($_POST['packagedeal']);
- $day1 = mysql_escape_string($_POST['day1']);
- $day2 = mysql_escape_string($_POST['day2']);
- $day3 = mysql_escape_string($_POST['day3']);
- $hascommunity = mysql_escape_string($_POST['hascommunity']);
- $community = mysql_escape_string($_POST['community']);
- $food = mysql_escape_string($_POST['food']);
- $sjufhotel = mysql_escape_string($_POST['sjuf-hotel']);
- $sjufroom = mysql_escape_string($_POST['sjuf-room']);
- $roommate1 = mysql_escape_string($_POST['roommate1']);
- $roommate2 = mysql_escape_string($_POST['roommate2']);
-
- if ( $hascommunity == "no" ) $community = "";
- if ( $sjufroom == "single" ) {
- $roommate1 = "";
- $roommate2 = "";
- }
-
- if ( $sjufroom == "double" ) $roommate2 = "";
-
- $price = 0;
-
- $attending = '';
-
- if ( $packagedeal == 'yes' ) {
- $price = 1800;
- $attending = 'You will attend all three days.';
- } else {
- $attending = 'You will attend:<br />';
- if ($day1 == "true") {
- $price += 800;
- $attending .= 'Day 1: Lets Get It Started 29/12<br />';
- }
- if ($day2 == "true") {
- $price += 400;
- $attending .= 'Day 2: The Spiritual Day 30/12<br />';
- }
- if ($day3 == "true") {
- $price += 900;
- $attending .= 'Day 3: The Major Countdown 31/12<br />';
- }
- }
-
- // Save info to database
- define('__ROOT__', dirname(dirname(__FILE__)));
- require_once(__ROOT__.'/includes/config.php');
-
- $db_conn=mysql_connect($db_host, $db_user, $db_pass);
-
- mysql_query("SET NAMES 'utf8'") or die(mysql_error());
- mysql_query("SET CHARACTER SET 'utf8'") or die(mysql_error());
-
- mysql_select_db($db_name, $db_conn);
-
- $res = mysql_query('INSERT INTO registrations (name, birth, gender, mail, mobile, address, postal, city, country, packagedeal, day1, day2, day3, community, food, hotel, room, roommate1, roommate2) VALUES ("'.$name.'","'.$birth.'","'.$gender.'","'.$mail.'","'.$mobile.'","'.$address.'","'.$postal.'","'.$city.'","'.$country.'","'.$packagedeal.'",'.$day1.','.$day2.','.$day3.',"'.$community.'","'.$food.'","'.$sjufhotel.'","'.$sjufroom.'","'.$roommate1.'","'.$roommate2.'")');
-
- $res = mysql_query('INSERT INTO registrationsbackup (name, birth, gender, mail, mobile, address, postal, city, country, packagedeal, day1, day2, day3, community, food, hotel, room, roommate1, roommate2) VALUES ("'.$name.'","'.$birth.'","'.$gender.'","'.$mail.'","'.$mobile.'","'.$address.'","'.$postal.'","'.$city.'","'.$country.'","'.$packagedeal.'",'.$day1.','.$day2.','.$day3.',"'.$community.'","'.$food.'","'.$sjufhotel.'","'.$sjufroom.'","'.$roommate1.'","'.$roommate2.'")');
-
- $id = mysql_insert_id();
-
-
- // Send mail to administrator
-
- $message = '<html><head></head><body>';
- $message .= 'Registration id: ' . $id . '<br />';
- $message .= 'Name: ' . $name . '<br />';
- $message .= 'Birthday: ' . $birth . '<br />';
- $message .= 'Gender: ' . $gender . '<br />';
- $message .= 'Mail: ' . $mail . '<br />';
- $message .= 'Mobile phone: ' . $mobile . '<br />';
- $message .= 'Address: ' . $address . '<br />';
- $message .= 'Postal: ' . $postal . '<br />';
- $message .= 'City: ' . $city . '<br />';
- $message .= 'Country: ' . $country . '<br />';
- $message .= 'Jewish Community: ' . $community . '<br />';
- $message .= 'Packagedeal: ' . $packagedeal . '<br />';
- $message .= 'Day 1: ' . $day1 . '<br />';
- $message .= 'Day 2: ' . $day2 . '<br />';
- $message .= 'Day 3: ' . $day3 . '<br />';
- $message .= 'Day 4: ' . $day4 . '<br />';
- $message .= 'Food preferences: ' . $food . '<br />';
- $message .= 'Book me a room? ' . $sjufhotel . '<br />';
- $message .= 'What kind of room? ' . $sjufroom . '<br />';
- $message .= 'Roommate 1: ' . $roommate1 . '<br />';
- $message .= 'Roommate 2: ' . $roommate2 . '<br />';
- $message .= '</body>';
-
-
- // To send HTML mail, the Content-type header must be set
- $headers = 'MIME-Version: 1.0' . "\r\n";
- //$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
- $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
-
-
- $headers .= 'From: Sjuf Registration <adam@sjuf12.dk>' . "\r\n" .
- 'Reply-To: adam@sjuf12.dk' . "\r\n" .
- 'To: adam@sjuf12.dk' . "\r\n" .
- 'X-Mailer: PHP/' . phpversion();
-
- echo $id;
- echo $message;
- echo $headers;
- mail('adam@sjuf12.dk', 'Ny registrering till sjuf12 - ID ' . $id, $message, $headers);
-
-
- // Send mail to guest
- $message = '<html>';
- $message .= '<style type="text/css">body, p {font: 16px/1.5 helvetica, arial, sans-serif; color: #000;}</style>';
- $message .= '<body>';
- $message .= ' <table cellspacing="0" width="100%">';
- $message .= ' <tr>';
- $message .= ' <td align="center">';
- $message .= ' <table cellspacing="0" width="600px">';
- $message .= ' <tr>';
- $message .= ' <td style="border: 2px solid black; text-align: center; padding: 10px;">';
- $message .= ' <h1 style="text-transform: uppercase; text-decoration: underline; font-size: 21px; text-align: left;">Congratulations</h1>';
- $message .= ' <p>You are now <strong>registered</strong> to SJUF 2011 in Malmö</p>';
- $message .= ' <p>I hope you are ready to get your mind blown. Just don't forget to tell your friends to register as soon as possible. Don't take no for an answer.</p>';
- $message .= ' <p>All <strong>information</strong> needed will be sent to you before the event.</p>';
- $message .= ' <p>If you have any questions don't hesitate to contact us</p>';
- $message .= ' <p><strong>Phonenumber:</strong> +46735038109<br /><strong>E-mail:</strong> <a href="mailto:sjufmalmo@gmail.com">sjufmalmo@gmail.com</a></p> ';
- $message .= ' </td>';
- $message .= ' </tr>';
-
- $message .= ' <tr>';
- $message .= ' <td style="padding: 10px;">';
- $message .= ' <h1 style="text-transform: uppercase; text-decoration: underline; font-size: 21px; text-align: left;">Payment Information</h1>';
- $message .= ' </td>';
- $message .= ' </tr>';
- $message .= ' <tr>';
- $message .= ' <td style="background: #000; color: #fff; text-align: center; padding: 10px;">';
- $message .= ' <p style="color: #FFFFFF"><strong>To complete the registration</strong> you have to make the payment within 30 days.</p>';
- $message .= ' <p style="color: #FFFFFF"><strong>Or else</strong> your registration will be canceled</p>';
- $message .= ' <p style="color: #FFFFFF"><strong>If you registered after 10th November</strong> the payment have to be done before 10th December</p> ';
- $message .= ' </td>';
- $message .= ' </tr>';
- $message .= ' <tr>';
- $message .= ' <td style="padding: 10px;">';
- $message .= ' ';
- $message .= ' </td>';
- $message .= ' </tr>';
- $message .= ' <tr>';
- $message .= ' <td style="border: 2px solid black; text-align: center; padding: 10px;">';
- $message .= ' <h2 style="text-transform: none; text-decoration: underline; font-size: 24px; text-align: center; font-weight: bold; margin-bottom: 0px; font-style: italic;">Swedish guests transfer to</h2>';
- $message .= ' <p style="margin-top: 0"><strong>Plusgiro:</strong> 52 48 94-3</p>';
- $message .= ' <h2 style="text-transform: none; text-decoration: underline; font-size: 24px; text-align: center; font-weight: bold; margin-bottom: 0px; font-style: italic;">All other guests transfer to</h2>';
- $message .= ' <p style="margin-top: 0"><strong>IBAN:</strong> SE50 9500 0099 6018 0524 8943<br /><strong>BIC-code: </strong>NDEASESS</p>';
- $message .= ' <p style="padding: 10px; color: #FFFFFF; background: #000000;">Amount to pay: '.$price.' SEK</p>';
- $message .= ' <p>* Remember to <strong>write your name or registration id</strong> as a message during your payment<br />';
- $message .= ' ** Remember that the prices are in SEK</p>';
- $message .= ' <h2 style="text-transform: none; text-decoration: underline; font-size: 24px; text-align: center; font-weight: bold; margin-bottom: 0px; font-style: italic;">Bank</h2>';
- $message .= ' <p style="margin-top: 0">Nordea</p>';
- $message .= ' </td>';
- $message .= ' </tr>';
- $message .= ' <tr>';
- $message .= ' <td style="padding: 10px;">';
- $message .= ' ';
- $message .= ' </td>';
- $message .= ' </tr>';
- $message .= ' <tr>';
- $message .= ' <td style="text-align: center; padding: 10px; border: 2px solid black;">';
- $message .= ' <h1 style="text-transform: uppercase; text-decoration: underline; font-size: 21px; text-align: left;">Registered information</h1>';
- $message .= ' <p>';
- $message .= ' <strong>Registration Id:</strong> '.$id.'<br />';
- $message .= ' <strong>Name:</strong> '.ucwords(strtolower($name)).'<br />';
- $message .= ' <strong>Birth:</strong> '.$birth.'<br />';
- $message .= ' <strong>Gender:</strong> '.ucwords(strtolower($gender)).'<br />';
- $message .= ' <strong>E-mail:</strong> '.$mail.'<br />';
- $message .= ' <strong>Mobile Phone:</strong> '.$mobile.'<br />';
- $message .= ' <strong>Address:</strong> '.ucwords(strtolower($address)).'<br />';
- $message .= ' <strong>Postal Code:</strong> '.$postal.' '.ucwords(strtolower($city)).'<br/>';
- $message .= ' <strong>Country:</strong> '.ucwords(strtolower($country)).'<br /> ';
- $message .= ' <h1 style="text-transform: uppercase; text-decoration: underline; font-size: 21px; text-align: left;">Chosen package</h1>';
- $message .= ' <p>'.$attending.'</p>';
- $message .= ' <h1 style="text-transform: uppercase; text-decoration: underline; font-size: 21px; text-align: left;">Additional information</h1>';
- $message .= ' <p>';
- if ( $hascommunity == 'yes' ) {
- $message .= ' <strong>Jewish community:</strong> '.ucwords(strtolower($community)).'<br />';
- }
-
- if ( $food != '' ) {
- $message .= ' <strong>Food preferences:</strong> '.ucwords(strtolower($food)).'<br />';
- }
- if ( $sjufhotel == 'yes' ) {
- $message .= ' <strong>Sjuf Hotel:</strong> We will reserve you a room<br />';
- }
- if ( $sjufhotel == 'yes' ) {
- $message .= ' <strong>Room:</strong> '.ucwords(strtolower($sjufroom)).'room<br />';
- }
- if ( $roommate1 != '' ) {
- $message .= ' <strong>Roommate(s):</strong> '.ucwords(strtolower($roommate1));
-
- if ( $roommate2 != '' ) {
- $message .= ' & '.ucwords(strtolower($roommate2));
-
- }
- }
-
-
-
- $message .= ' </p>';
- $message .= ' </td>';
- $message .= ' </tr>';
- $message .= ' </table>';
- $message .= ' </td>';
- $message .= ' </tr>';
- $message .= ' </table>';
- $message .= '</body>';
- $message .= '</html>';
-
-
- // To send HTML mail, the Content-type header must be set
- $headers = 'MIME-Version: 1.0' . "\r\n";
- $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
-
- $headers .= 'To: '.$name.' <'.$mail.'>' . "\r\n" .
- 'From: Sjuf Registration <adam@sjuf12.dk>' . "\r\n" .
- 'Reply-To: adam@sjuf12.dk' . "\r\n";
-
-
-
-
- $successtext = 'Your registration has been completed.';
-
- if (mail($mail, 'Registration Confirmation Sjuf11 ID ' . $id, $message, $headers)) {
- $successtext .= 'We have sent an e-mail to '.$mail.' with your confirmation. Please refer to that mail for more details concerning your registration.';
- }
-
- if ($res) {
- echo "<h1>Thanks for your registration</h1>";
- echo "<p>Hello ".ucwords(strtolower($name)).",<br /><br />" . wordwrap($successtext, 70, "<br />") . "</p>";
- }
-
-
-
- ?>
@gustav,
Hvad mener du om min maildeamon kører, siden er oppe på et webhotel.
Hvordan er det jeg laver en reduced test case?
Og nej jeg får ingen fejl, tværtimod, jeg får succestekst beskeden, som om det skulle virke.
Den kan godt indsætte posterne i databasen bare ikke sende mailene.
Indlæg senest redigeret d. 02.09.2012 22:43 af Bruger #14317