Click here to Skip to main content
15,886,806 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
GeneralRe: How to send email? and How to display text Lyrics when-a link is clicked Pin
CoderForEver23-Oct-09 0:03
CoderForEver23-Oct-09 0:03 
Questiongetting data from files Pin
stevieke16-Oct-09 3:09
stevieke16-Oct-09 3:09 
AnswerRe: getting data from files Pin
cjoki16-Oct-09 7:54
cjoki16-Oct-09 7:54 
Questiondatetime.now Pin
Artakazezs12-Oct-09 2:46
Artakazezs12-Oct-09 2:46 
AnswerRe: datetime.now Pin
Luc Pattyn12-Oct-09 2:58
sitebuilderLuc Pattyn12-Oct-09 2:58 
AnswerRe: datetime.now Pin
EliottA12-Oct-09 3:54
EliottA12-Oct-09 3:54 
QuestionLittle help with my php code pls Pin
wartotojas11-Oct-09 2:34
wartotojas11-Oct-09 2:34 
AnswerRe: Little help with my php code pls Pin
fly90411-Oct-09 6:26
fly90411-Oct-09 6:26 
wartotojas wrote:
die('{status: 0,txt:"This email address is already registered"}');


The die function stops the process from running, so every thing after die is not executed.



wartotojas wrote:
if($username_exist > 0){
die('{status:0,txt:"This email address is already registered"}');
unset($email);
include 'register.html';
exit();

// lf no errors present with the username
// use a query to insert the data into the database.

$query = "INSERT INTO users (name, lname, email, nickname, password)
VALUES('$name', '$lname', '$email', '$nickname', '$password')";
mysql_query($query) or die(mysql_error());
mysql_close();

echo "You have successfully Registered";


Why are you using die and exit? Where is the if tag closed? I can see the curly bracket open, but not close.

This should work. Notice that I dont use die or exit (apart from if the query fails):

// If the username exists then:
// 1: Close the MySQL connection.
// 2: Output that the email has already been registered.
// 3: Include the registration file.
if ( $username_exist > 0 )
{
   mysql_close();
   echo 'Email already registered';
   include( 'register.html' );
}

// Otherwise (If the username doesn't exist):
// 1: Insert the new user.
// 2: Close the MySQL connection.
// 3: Output that the user has been registered.
else
{
   $query = "INSERT INTO users (name, lname, email, nickname, password)
     VALUES('$name', '$lname', '$email', '$nickname', '$password')";
   mysql_query( $query ) or die( mysql_error() );
   mysql_close();

   echo "You have successfully Registered";
}


If at first you don't succeed, you're not Chuck Norris.

GeneralRe: Little help with my php code pls Pin
wartotojas11-Oct-09 9:54
wartotojas11-Oct-09 9:54 
GeneralRe: Little help with my php code pls Pin
fly90411-Oct-09 10:24
fly90411-Oct-09 10:24 
GeneralRe: Little help with my php code pls Pin
cjoki12-Oct-09 6:12
cjoki12-Oct-09 6:12 
GeneralRe: Little help with my php code pls Pin
fly90412-Oct-09 6:54
fly90412-Oct-09 6:54 
GeneralRe: Little help with my php code pls [modified] Pin
cjoki12-Oct-09 7:54
cjoki12-Oct-09 7:54 
GeneralRe: Little help with my php code pls Pin
fly90412-Oct-09 9:01
fly90412-Oct-09 9:01 
GeneralRe: Little help with my php code pls Pin
cjoki12-Oct-09 9:34
cjoki12-Oct-09 9:34 
GeneralRe: Little help with my php code pls Pin
fly90412-Oct-09 10:22
fly90412-Oct-09 10:22 
GeneralRe: Little help with my php code pls [modified] Pin
cjoki12-Oct-09 11:03
cjoki12-Oct-09 11:03 
GeneralRe: Little help with my php code pls Pin
fly90412-Oct-09 11:50
fly90412-Oct-09 11:50 
GeneralRe: Little help with my php code pls Pin
cjoki12-Oct-09 12:20
cjoki12-Oct-09 12:20 
GeneralRe: Little help with my php code pls Pin
fly90412-Oct-09 12:38
fly90412-Oct-09 12:38 
GeneralRe: Little help with my php code pls Pin
cjoki13-Oct-09 5:05
cjoki13-Oct-09 5:05 
Questioninstallation Pin
WilliamSimon8-Oct-09 12:07
WilliamSimon8-Oct-09 12:07 
Questioninstallation Pin
thangvel8-Oct-09 11:54
thangvel8-Oct-09 11:54 
AnswerRe: installation Pin
Richard MacCutchan14-Oct-09 6:07
mveRichard MacCutchan14-Oct-09 6:07 
AnswerRe: installation Pin
Iranian MM7-Sep-11 9:40
Iranian MM7-Sep-11 9:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.