Click here to Skip to main content
16,020,974 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
AnswerRe: How to send email? and How to display text Lyrics when-a link is clicked Pin
CalvinHartwell19-Oct-09 11:04
CalvinHartwell19-Oct-09 11:04 
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 
hi everybody,

Im new with php, started recently, Im making a registration form for my website and here is the problem. I try to check if email address entered isn't already in use. here is the code Im using:

mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());

    
$name = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];    
$nickname = $_POST['nickname'];
$password = md5($_POST['password']);

// lets check to see if the username already exists
$checkuser = mysql_query("SELECT email FROM users WHERE email='$email'"); 

$username_exist = mysql_num_rows($checkuser);

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";

It does the job, doesnt send data to database if email is registered, but it allways displays error message
{status:0,txt:"This email address is already registered"}, 
and don't output message that you have been registered. If email address is unique it creates a record in a database, but displays error and doesnt redirect. Its probably something simple, but I cant figure out by my self. Anyone any ideas?

By the way my form includes jQuery and few functions if it makes any difference.

thanx in advance
AnswerRe: Little help with my php code pls Pin
fly90411-Oct-09 6:26
fly90411-Oct-09 6:26 
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 

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.