Jump to content

Recommended Posts

I've got this code I've been working on and it was working for a while but recently I changed the page and I've lost the functionality of the validate username and password entries.

 

if anyone sees why this stoped working please help...

 

<?php 

if(isset($_POST['Submit'])){
//NEED TO CHECK IF FIELDS ARE FILLED IN
if( empty($_POST['name'])){
header("Location:Messages1.php?msg=17"); 
exit();
}

if( empty($_POST['email'])){
header("Location:Messages1.php?msg=16"); 
exit();
}

if( empty($_POST['pw1']) && (empty($_POST['pw2']))){
header( "Location:Messages1.php?msg=4" ); 
exit();
}

if( empty($_POST['f_name']) && (empty($_POST['l_name']))){
header( "Location:Messages1.php?msg=15" ); 
exit();
}

if( empty($_POST['legal_accept'])){
header( "Location:Messages1.php?msg=14" ); 
exit();
}

$name=$_POST['name'];
$email=$_POST['email'];
$f_name=$_POST['f_name'];
$l_name=$_POST['l_name'];
$zip_code=$_POST['zip_code'];
$e_private=$_POST['e_private'];
$country=$_POST['country'];
$bio=$_POST['bio'];
$occupation=$_POST['occupation'];
$occupation_other=$_POST['occupation_other'];
$website=$_POST['website'];
$date_joined=date("D, F jS, Y \@ g:i a T"); //create date time
$user_image=$_POST['user_image'];
$legal_accept=$_POST['legal_accept'];

$pw1=$_POST['pw1'];
$pw2=$_POST['pw2'];

if("$pw1" !== "$pw2"  ){
header( "Location:Messages1.php?msg=5" ); 
exit();
}
$ip = $_SERVER['REMOTE_ADDR'];

//connect to the db server , check if uname exist
include('config.php');
$query=("Select * from user where uname='$name'");
$result= mysql_query($query); 
$num=mysql_num_rows($result);

if(
ctype_alnum($pw1) // numbers & digits only
&& strlen($pw1)>6 // at least 7 chars
&& strlen($pw1)<21 // at most 20 chars
){
// valid
}else{
header( "Location:Messages1.php?msg=12" );
}

if(
ctype_alnum($name) // numbers & digits only
&& strlen($name)>6 // at least 7 chars
&& strlen($name)<21 // at most 20 chars
){
// valid
}else{
header( "Location:Messages1.php?msg=13" );
}

if ($num > 0) {//Username already exist
header( "Location:Messages1.php?msg=6" ); 
exit();
}else{
//if username does not exist insert user details
$query=( "INSERT INTO user (f_name,l_name,zip_code,e_private,country,bio,occupation,occupation_other,website,uname,pw,email,date_joined,user_image,legal_accept,ip,level) VALUES ('$f_name','$l_name','$zip_code','$e_private','$country','$bio','$occupation','$occupation_other','$website','$name','$pw1','$email','$date_joined','$user_image','$legal_accept','$ip','Normal')");
if (@mysql_query ($query)) {
header("location:login.php?reg=1");
exit;
}else
  die(mysql_error());
}
mysql_close();
}
?>

 

 

I feel like my problem is around this part.

if(
ctype_alnum($pw1) // numbers & digits only
&& strlen($pw1)>6 // at least 7 chars
&& strlen($pw1)<21 // at most 20 chars
){
// valid
}else{
header( "Location:Messages1.php?msg=12" );
}

if(
ctype_alnum($name) // numbers & digits only
&& strlen($name)>6 // at least 7 chars
&& strlen($name)<21 // at most 20 chars
){
// valid
}else{
header( "Location:Messages1.php?msg=13" );
}

 

 

um...your code says "run the query, then send them to the login page"

$query=( "INSERT INTO user (f_name,l_name,zip_code,e_private,country,bio,occupation,occupation_other,website,uname,pw,email,date_joined,user_image,legal_accept,ip,level) VALUES ('$f_name','$l_name','$zip_code','$e_private','$country','$bio','$occupation','$occupation_other','$website','$name','$pw1','$email','$date_joined','$user_image','$legal_accept','$ip','Normal')");
if (@mysql_query ($query)) {
header("location:login.php?reg=1");
exit;

it's not sending you to login.php?reg=1 ?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.