Error for registration mail.

Error for registration mail.

am 07.01.2007 16:02:03 von Chris Carter

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.


// 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@GurgaonShoppingMalls.com");


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

Re: Error for registration mail.

am 07.01.2007 17:48:51 von Niel Archer

Hi

You have two functions between the if and else, the syntax you've used
only allows one. Use braces.

if(mysql_query($sql)) {
mail ($email, "Thank you for registering!", $body, "From:
Malls@GurgaonShoppingMalls.com");
header("Location: thankYou.php");
} else {
die("Error! Could not insert values".mysql_error());
}


Niel

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

Re: Error for registration mail.

am 09.01.2007 12:30:56 von Niel Archer

------=_NextPart_3a3_b721_89904ea6.f15dd73c_.MIX
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi

You have two functions between the if and else, the syntax you've used
only allows one. Use braces.

if(mysql_query($sql)) {
mail ($email, "Thank you for registering!", $body, "From:
Malls@GurgaonShoppingMalls.com");=20
header("Location: thankYou.php");
} else {
die("Error! Could not insert values".mysql_error());
}


Niel

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




************************************************************ **********

IMPORTANT NOTICE

This communication is for the exclusive use of the intended recipient(s)
named above. If you receive this communication in error, you should
notify the sender by e-mail or by telephone (+44) 191 224 4461, delete
it and destroy any copies of it.

This communication may contain confidential information and material
protected by copyright, design right or other intellectual property
rights which are and shall remain the property of Piranha Studios
Limited. Any form of distribution, copying or other unauthorised use
of this communication or the information in it is strictly prohibited.
Piranha Studios Limited asserts its rights in this communication and
the information in it and reserves the right to take action against
anyone who misuses it or the information in it.

Piranha Studios Limited cannot accept any liability sustained as a
result of software viruses and would recommend that you carry out your
own virus checks before opening any attachment.

************************************************************ ************
<<<>>>
------=_NextPart_3a3_b721_89904ea6.f15dd73c_.MIX
Content-Type: text/plain;
name="GWAVADAT.TXT"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="GWAVADAT.TXT"

AdmID:AB921E10C335AA36444D22D567C6AA92



************************************************************ **********

IMPORTANT NOTICE

This communication is for the exclusive use of the intended recipient(s)
named above. If you receive this communication in error, you should
notify the sender by e-mail or by telephone (+44) 191 224 4461, delete
it and destroy any copies of it.

This communication may contain confidential information and material
protected by copyright, design right or other intellectual property
rights which are and shall remain the property of Piranha Studios
Limited. Any form of distribution, copying or other unauthorised use
of this communication or the information in it is strictly prohibited.
Piranha Studios Limited asserts its rights in this communication and
the information in it and reserves the right to take action against
anyone who misuses it or the information in it.

Piranha Studios Limited cannot accept any liability sustained as a
result of software viruses and would recommend that you carry out your
own virus checks before opening any attachment.

************************************************************ ************
<<<>>>

------=_NextPart_3a3_b721_89904ea6.f15dd73c_.MIX
Content-Type: text/plain; charset=us-ascii

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
------=_NextPart_3a3_b721_89904ea6.f15dd73c_.MIX--