Jump to content

email validation doesnt work


darkfreaks

Recommended Posts

im not sure why it skips  email validation? any thoughts?

 

 

<?phph
session_start();
include_once "../functions.php";
include_once "../main.php";
include_once "../configuration.inc.php";

if ($upass == $cpass) 
{
   if (!empty($uname) && !empty($upass) && !empty($cpass) && !empty($title) && !empty($fname) && !empty($lname) && !empty($city) && !empty($country) && !empty($zip) && !empty($address) && !empty($phone) && !empty($job_seeker_email) && !empty($JobCategory) && !empty($careerlevel))
     {
if (is_array($JobCategory))
{
	$JobStr = implode("," , $JobCategory);
}

	if($careerlevel == '1')
	{
		$clname = 'Student (High School)';
	}
	elseif($careerlevel == '2')
	{
		$clname = 'Student (undergraduate/graduate)';
	}
	elseif($careerlevel == '3')
	{
		$clname = 'Entry Level (less than 2 years of experience)';
	}
	elseif($careerlevel == '4')
	{
		$clname = 'Mid Career (2+ years of experience)';
	}
	elseif($careerlevel == '5')
	{
		$clname = 'Management (Manager/Director of Staff)';
	}
	elseif($careerlevel == '6')
	{
		$clname = 'Executive (SVP, EVP, VP)';
	}
	elseif($careerlevel == '7')
	{
		$clname = 'Senior Executive (President, CEO)';
	}
              $query= mysql_real_escape_string($query);
      $query= strip_tags($query);
      $query= trim($query);
       $query= RemoveXSS($query);
     $query = "insert into job_seeker_info set 
	uname = \"$uname\",
	upass = \"$upass\",
	title = \"$title\",
	fname = \"$fname\",
	lname = \"$lname\",
	income = \"$income\",
	city = \"$city\",
	state = \"$state\",
	country = \"$country\",
	zip = \"$zip\",
	address = \"$address\",
	phone = \"$phone\",
	phone2 = \"$phone2\",
	job_seeker_email = \"$job_seeker_email\",
	job_seeker_web = \"$job_seeker_web\",
	job_category = \"$JobStr\",
	careerlevel = \"$clname\",
	target_company = \"$target_company\",
	relocate = \"$relocate\"
	";

	$result = mysql_query($query) or die('<br><br><center> <?=$EREG?> </center>');

               $qcl= mysql_real_escape_string($qcl);
       $qcl= strip_tags($qcl);
       $qcl= trim($qcl);
        $qc1= RemoveXSS($qc1);
	$qcl = "insert into job_careerlevel set
		uname = \"$uname\",
		clnumber = \"$careerlevel\",
		clname = \"$clname\" ";
	$rcl = mysql_query($qcl) or die(mysql_error());


$to = $job_seeker_email;
$subject = "Your account at $mydomain";
$message = "This is your account information at $mydomain\n\n username: $uname\n password: $upass\n\n\n Keep this information in a secure place. \n\n Thanks for your registration. We believe you will find a job at \n http://$myurl";
$from = "From: <$contactemail>";

mail($to, $subject, $message,$from);

$_SESSION["uname"]=$uname;
$_SESSION["upass"]=$upass;



	echo "<br><br><br> 
	<p align=center>
	Thank you ! You are now registered as a job seeker.<br>Start <a href=post-resume.php>building your resume</a> or <a href=job-search.php> search for a job</a>.
	</p>
	";

        }
        else
        {
echo "<center><br><br><br><font color=red><b> You miss to fill some of the required fields.<br> Please go <a class=ERR href=jobseeker_registration.php> back</a> and fill all of them properly.</b></font></center>";
        }
}
else
{
echo "<center><br><br><br><font color=red><b> The password/confirm password fields don`t match. <br> Please go <a class=ERR href=jobseeker_registration.php> back</a> and fill them properly.</b></font></center>";
}
if (isset($_POST['job_seeker_email']))
         {
            if (isValidEmail($_POST['job_seeker_email'])){
                echo "<tr><td>The email: ".$_POST['job_seeker_email']." is valid!</td></tr>";
            }
            else{
                echo "<tr><td>The email: ".$_POST['job_seeker_email']." is invalid!</td></tr>";
            }
         }


?>


<?php include_once('../footer.php'); ?>

Link to comment
https://forums.phpfreaks.com/topic/80803-email-validation-doesnt-work/
Share on other sites

try this

 

<?php
session_start();
include_once "../functions.php";
include_once "../main.php";
include_once "../configuration.inc.php";

if ($upass == $cpass) 
{
   if (!empty($uname) && !empty($upass) && !empty($cpass) && !empty($title) && !empty($fname) && !empty($lname) && !empty($city) && !empty($country) && !empty($zip) && !empty($address) && !empty($phone) && !empty($job_seeker_email) && !empty($JobCategory) && !empty($careerlevel))
     {
if (is_array($JobCategory))
{
	$JobStr = implode("," , $JobCategory);
}

	if($careerlevel == '1')
	{
		$clname = 'Student (High School)';
	}
	elseif($careerlevel == '2')
	{
		$clname = 'Student (undergraduate/graduate)';
	}
	elseif($careerlevel == '3')
	{
		$clname = 'Entry Level (less than 2 years of experience)';
	}
	elseif($careerlevel == '4')
	{
		$clname = 'Mid Career (2+ years of experience)';
	}
	elseif($careerlevel == '5')
	{
		$clname = 'Management (Manager/Director of Staff)';
	}
	elseif($careerlevel == '6')
	{
		$clname = 'Executive (SVP, EVP, VP)';
	}
	elseif($careerlevel == '7')
	{
		$clname = 'Senior Executive (President, CEO)';
	}
              $query= mysql_real_escape_string($query);
      $query= strip_tags($query);
      $query= trim($query);
       $query= RemoveXSS($query);
     $query = "insert into job_seeker_info set 
	uname = \"$uname\",
	upass = \"$upass\",
	title = \"$title\",
	fname = \"$fname\",
	lname = \"$lname\",
	income = \"$income\",
	city = \"$city\",
	state = \"$state\",
	country = \"$country\",
	zip = \"$zip\",
	address = \"$address\",
	phone = \"$phone\",
	phone2 = \"$phone2\",
	job_seeker_email = \"$job_seeker_email\",
	job_seeker_web = \"$job_seeker_web\",
	job_category = \"$JobStr\",
	careerlevel = \"$clname\",
	target_company = \"$target_company\",
	relocate = \"$relocate\"
	";

	$result = mysql_query($query) or die(mysql_error());

               $qcl= mysql_real_escape_string($qcl);
       $qcl= strip_tags($qcl);
       $qcl= trim($qcl);
        $qc1= RemoveXSS($qc1);
	$qcl = "insert into job_careerlevel set
		uname = \"$uname\",
		clnumber = \"$careerlevel\",
		clname = \"$clname\" ";
	$rcl = mysql_query($qcl) or die(mysql_error());


$to = $job_seeker_email;
$subject = "Your account at $mydomain";
$message = "This is your account information at $mydomain\n\n username: $uname\n password: $upass\n\n\n Keep this information in a secure place. \n\n Thanks for your registration. We believe you will find a job at \n http://$myurl";
$from = "From: <$contactemail>";

mail($to, $subject, $message,$from);

$_SESSION["uname"]=$uname;
$_SESSION["upass"]=$upass;



	echo "<br><br><br> 
	<p align=center>
	Thank you ! You are now registered as a job seeker.<br>Start <a href=post-resume.php>building your resume</a> or <a href=job-search.php> search for a job</a>.
	</p>
	";

        }
        else
        {
echo "<center><br><br><br><font color=red><b> You miss to fill some of the required fields.<br> Please go <a class=ERR href=jobseeker_registration.php> back</a> and fill all of them properly.</b></font></center>";
        }
}
else
{
echo "<center><br><br><br><font color=red><b> The password/confirm password fields don`t match. <br> Please go <a class=ERR href=jobseeker_registration.php> back</a> and fill them properly.</b></font></center>";
}
if (isset($_POST['job_seeker_email']))
         {
            if (isValidEmail($_POST['job_seeker_email'])){
                echo "<tr><td>The email: ".$_POST['job_seeker_email']." is valid!</td></tr>";
            }
            else{
                echo "<tr><td>The email: ".$_POST['job_seeker_email']." is invalid!</td></tr>";
            }
         }


?>


<?php include_once('../footer.php'); ?>

You are not using $_POST variables anywhere else in this script... is anything actually posted to this script? You have a multiple script structure here, so it's hard to tell what has already been done before this script was called. If nothing is posted to this script, then your problem should be solved by:

 

<?php
if ( isset($job_seeker_email) ) {
   if ( isValidEmail($job_seeker_email) ) {
       echo "<tr><td>The email: ".$job_seeker_email." is valid!</td></tr>";
   } else {
       echo "<tr><td>The email: ".$job_seeker_email." is invalid!</td></tr>";
   }
}

 

PhREEEk

 

<?php
// This function tests whether the email address is valid  
   function isValidEmail($job_seeker_email){
      $pattern = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$";
     
      if (eregi($pattern, $job_seeker_email)){
         return true;
      }
      else {
         return false;
      }      }?>

 

maybe my function is wrong? ???

 

When you say it 'skips' it, do you mean nothing gets echo'd? The way you have it setup, if $job_seeker_email is set, then one of two things are definitely going to print to screen. If $job_seeker_email is NOT set, then nothing will print.

 

Does anything print?

 

If something does print, I would assume the same one prints every time? In that case, your function is going to be our problem.

 

PhREEEk

nothing gets echoed and its bugging me.

 

i changed it to

 

<?php
function isValidEmail($job_seeker_email){


if 
(!preg_match("/^( [a-zA-Z0-9] )+( [a-zA-Z0-9\._-] )
*@( [a-zA-Z0-9_-] )+( [a-zA-Z0-9\._-] +)+$/" , $job_seeker_email)) {
  return false;
}
return true;}?>

 

still nothing gets outputted  ???

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.