I am trying to send an email to the user after he registers himself on the
website. The code is a DB code that

1) Inserts the data to DB table
2) Sends an email to the user with his details.
3) Passes on a Thank you page.

The code works fine without the email code. But I get this error when I put
this error.

   // database information
   $host = 'xxxx';      
   $user = 'xxxx';
   $password = 'xxxx';
   $dbName = 'xxxx';

    if ($_POST['submit']) {

   // connect and select the database
                $conn = mysql_connect($host, $user, $password) or 
                $db = mysql_select_db($dbName, $conn) or die(mysql_error());

   // insert new entry in the database if entry submitted
      $fName = $_POST['fName'];
          $lName = $_POST['lName'];
          $email = $_POST['email'];
          $confEmail = $_POST['confEmail'];
          $password = $_POST['password'];
          $confirmPassword = $_POST['confirmPassword'];
          $address = $_POST['address'];
          $city = $_POST['city'];
          $state = $_POST['state'];
          $postCode = $_POST['postCode'];
          $gender = $_POST['gender'];
          $profession = $_POST['profession'];
          $ageGroup = $_POST['ageGroup'];
          $mallPref = $_POST['mallPref'];
          $mailConsent = $_POST['mailConsent'];
          $body = "Thank you for registering with us\nYour password is
'{$_POST['password']}'. \n\nSincerely,\nGurgaonShoppingMalls"; 
      // insert new entry into database
      $sql = "insert into `userdata` (fName, lName, email, confEmail,
password, confirmPassword, address, city, state, postCode, gender,
profession, ageGroup, mallPref, mailConsent) VALUES ('$fName', '$lName',
'$email', '$confEmail', '$password', '$confirmPassword', '$address',
'$city', '$state', '$postCode', '$gender', '$profession', '$ageGroup',
'$mallPref', '$mailConsent')";
                 -->> This is the error part

 mail ($email, "Thank you for registering!", $body, "From:

                  header("Location: thankYou.php");
                  die("Error! Could not insert values".mysql_error());
   }  // end if new entry posted

I am getting this error:

Parse error: syntax error, unexpected T_ELSE in /xxx/xxx/xxx/xxx/xxx/xxx.php
on line 44 This is the file name. Please note that I am using a separate
file to insert the data and do all three jobs mentioned above. The line 44
refers to the mail portion of the code. If I comment the code, the data gets
into the database and thank you page is displayed.

Please advice where the code is wrong. Or if there is another simple
approach for doing this task.

Thanks in advance.

View this message in context: 
Sent from the Php - Database mailing list archive at Nabble.com.

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to