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

Linux, Apache, MySQL, PHP

 
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 
GeneralRe: Little help with my php code pls Pin
wartotojas11-Oct-09 9:54
wartotojas11-Oct-09 9:54 
I used die function few times, and it doesnt kill all process.

here is full php code Im using :
<?php

// we check if everything is filled in

if(empty($_POST['fname']) || empty($_POST['lname']) || empty($_POST['email']) || empty($_POST['nickname']) || empty($_POST['pass']))
{
	die('{status:0,txt:"All the fields are required"}');
}



// is the email valid?

if(!(preg_match("/^[\.A-z0-9_\-\+]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $_POST['email'])))
{	
	die('{status:0,txt:"You haven\'t provided a valid email"}');
}




$dbhost = "localhost";
$dbname = "register";
$dbuser = "*******";
$dbpass = "******";


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']);



$checkuser = mysql_query("SELECT email FROM users WHERE email='$email'"); 

$username_exist = mysql_num_rows($checkuser);
	
	if ( $username_exist > 0 ){   
		mysql_close();   
		echo 'Email already registered';   
		include( 'members.php' );
	}

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


It is still doesnt work. I used die('{status:0,txt:"You haven\'t provided a valid email"}'); to display error message in error box, before you are redirected, I tought it will work instead of echo statment and it is working with first few fields. Like I said before records are created in database in the way they are supposed to, the only thing is that error message I want to make for email validation. Any suggestion about that, and this might sound realy dumb, but how do I make that after registration and clicking submit button users would be redirected to other page, lets say "members.php"?

thanks for answers and any help Smile | :)
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 
Questiondownload php code Pin
udch7-Oct-09 1:24
udch7-Oct-09 1:24 

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.