i have been trying to make this code return an error for each item supplied. any thoughts?
<?
session_start();
include_once "../main.php";
include_once "../configuration.inc.php";
if ($upass == $cpass)
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 (!empty($uname)
{
Print "<br><br><font font size='2' face='Verdana' color='#000099'><b>Oops</b></font><font font size='2' face='Verdana' color='black'>, you forgot to fill in your Username.<br> Please go back and try again.</font>";
exit;
}
$result=mysql_query("SELECT * FROM job_seeker_info WHERE uname='$uname'");
if (mysql_num_rows($result) >=1)
{
Print "<br><br><font font size='2' face='Verdana' color='#000099'><b>Sorry </b></font><font font size='2' face='Verdana' color='black'>, that username is taken.<br> Please go back and try again.</font>";
}
&& !empty($fname)
{
Print "<br><br><font font size='2' face='Verdana' color='#000099'><b>Oops</b></font><font font size='2' face='Verdana' color='black'>, you forgot to fill in your first name.<br> Please go back and try again.</font>";
exit;
}
&& !empty($lname)
{
Print "<br><br><font font size='2' face='Verdana' color='#000099'><b>Oops</b></font><font font size='2' face='Verdana' color='black'>, you forgot to fill in your last name.<br> Please go back and try again.</font>";
exit;
}
&& !empty($job_seeker_email)
{
Print "<br><br><font font size='2' face='Verdana' color='#000099'><b>Oops</b></font><font font size='2' face='Verdana' color='black'>, you forgot to fill in your email address.<br> Please go back and try again.</font>";
exit;
}
)
else
{
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 = "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 = "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_register("uname");
session_register("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>
";
}
}
?>
<? include_once('../footer.php'); ?>
user registration script. help needed
Moderator: General Moderators
Re: user registration script. help needed
What exactly do you need - are you getting an error or something? Also, you need to wrap your code in code tags to make it easier to read in the forums.
Re: user registration script. help needed
Don't use Exit. And it wont stop executing the script.
Also your current messy and hard to read. I would suggest using an array to hold the errors.
Im not saying use functions like that, just an example.
Also your current messy and hard to read. I would suggest using an array to hold the errors.
Code: Select all
<?php
$Errors = array();
if(!validUsername()){
$Errors[] = 'Not valid......'; // .....
}
if(!validEmail()){
$Errors[] = 'Not valid......'; // .....
}
// etc.
// Then to check if there are errors.
if(!empty($Errors)){
// No Errrors
}else{
// Errors
}
Re: user registration script. help needed
this script is suppose to validate new user sign up by verifying if some required fields were left empty or not. then proceed to send an email using the default webmaster email to the new user.
Code: Select all
<?
session_start();
include_once "../main.php";
include_once "../configuration.inc.php";
if ($upass == $cpass)
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 (!empty($uname)
{
Print "<br><br><font font size='2' face='Verdana' color='#000099'><b>Oops</b></font><font font size='2' face='Verdana' color='black'>, you forgot to fill in your Username.<br> Please go back and try again.</font>";
}
$result=mysql_query("SELECT * FROM job_seeker_info WHERE uname='$uname'");
if (mysql_num_rows($result) >=1)
{
Print "<br><br><font font size='2' face='Verdana' color='#000099'><b>Sorry </b></font><font font size='2' face='Verdana' color='black'>, that username is taken.<br> Please go back and try again.</font>";
}
$!empty($fname)
{
Print "<br><br><font font size='2' face='Verdana' color='#000099'><b>Oops</b></font><font font size='2' face='Verdana' color='black'>, you forgot to fill in your first name.<br> Please go back and try again.</font>";
}
$!empty($lname)
{
Print "<br><br><font font size='2' face='Verdana' color='#000099'><b>Oops</b></font><font font size='2' face='Verdana' color='black'>, you forgot to fill in your last name.<br> Please go back and try again.</font>";
exit;
}
$ !empty($job_seeker_email)
{
Print "<br><br><font font size='2' face='Verdana' color='#000099'><b>Oops</b></font><font font size='2' face='Verdana' color='black'>, you forgot to fill in your email address.<br> Please go back and try again.</font>";
exit;
}
)
else
{
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 = "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 = "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_register("uname");
session_register("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>
";
}
}
?>
<? include_once('../footer.php'); ?>
Re: user registration script. help needed
Areas like:
Would be better suited like this:
Code: Select all
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)';
}Code: Select all
switch($careerlevel){
case 1:
$clname = 'Student (High School)';
break;
case 2:
$clname = 'Student (undergraduate/graduate)';
break;
case 3:
$clname = 'Entry Level (less than 2 years of experience)';
break;
case 4:
$clname = 'Mid Career (2+ years of experience)';
break;
case 5:
$clname = 'Management (Manager/Director of Staff)';
break;
case 6:
$clname = 'Executive (SVP, EVP, VP)';
break;
case 7:
$clname = 'Senior Executive (President, CEO)';
break;
}Re: user registration script. help needed
Inkyskin, thanks. I think it makes the code lighter. But do u see any errors with the entire code?
thanks
thanks
Re: user registration script. help needed
To be honest, the code is extremely messy, and VERY hard to read. Does it produce any error messages? Or does it work fine? The style of the code is also very inconsistent - was it written by more than one person?