Error for registration mail.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

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.

<?php
   
   // 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 die(mysql_error());
		$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')";
   
	  if(mysql_query($sql))
		    
		 -->> This is the error part

 mail ($email, "Thank you for registering!", $body, "From:
Malls@xxxxxxxxxxxxxxxxxxxxxxxx"); 


		  header("Location: thankYou.php");
		  
	  else
		  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.

Chris
-- 
View this message in context: http://www.nabble.com/Error-for-registration-mail.-tf2934743.html#a8205031
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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux