science-ation/register_judges.php
james 1b393c1bb0 Commit all work from the weekend:
- judges registration
 - small changes to participant registraiton
2004-12-19 23:16:46 +00:00

138 lines
3.7 KiB
PHP

<?
require("common.inc.php");
if($_POST['action']=="new")
{
//first make sure their password is good
if(!$_POST['pass1'])
{
send_header("Judges Registration");
echo error(i18n("Password is required"));
$_POST['action']="login";
}
else if($_POST['pass1'] != $_POST['pass2'])
{
send_header("Judges Registration");
echo error(i18n("Passwords do not match"));
$_POST['action']="login";
}
else
{
mysql_query("INSERT INTO judges (email,password) VALUES ('".$_SESSION['email']."','".$_POST['pass1']."')");
$id=mysql_insert_id();
$_SESSION['judges_id']=$id;
//obviously if they are signing up right now they would like to particapte in the current years fair, so setup the year for them
mysql_query("INSERT INTO judges_years (judges_id,year) VALUES ('$id','".$config['FAIRYEAR']."')");
//now redirect to jduges main
header("Location: register_judges_main.php");
}
}
else if($_POST['action']=="continue")
{
if($_POST['pass'])
{
$q=mysql_query("SELECT * FROM judges WHERE email='".$_SESSION['email']."' AND password='".$_POST['pass']."'");
if(mysql_num_rows($q)==1)
{
$r=mysql_fetch_object($q);
$_SESSION['judges_id']=$r->id;
header("Location: register_judges_main.php");
}
else
{
send_header("Judges Registration");
echo error(i18n("Invalid Password"));
$_POST['action']="login";
}
}
else
{
send_header("Judges Registration");
echo error(i18n("Password missing"));
$_POST['action']="login";
}
}
else if($_GET['action']=="logout")
{
unset($_SESSION['email']);
unset($_SESSION['judges_id']);
send_header("Judges Registration");
echo notice(i18n("You have been successfully logged out"));
}
send_header("Judges Registration");
if($_POST['action']=="login" && ( $_POST['email'] || $_SESSION['email']) )
{
if($_POST['email'])
$_SESSION['email']=$_POST['email'];
echo "<form method=\"post\" action=\"register_judges.php\">";
$allownew=true;
//first, check if they have any registrations waiting to be opened
$q=mysql_query("SELECT * FROM judges WHERE email='".$_SESSION['email']."'");
if(mysql_num_rows($q)>0)
{
echo i18n("Please enter your password to login");
echo "<br />";
echo "<br />";
echo i18n("Password:")." ";
echo "<input type=\"password\" size=\"10\" name=\"pass\">";
echo "<input type=\"hidden\" name=\"action\" value=\"continue\">";
echo "<input type=\"submit\" value=\"".i18n("Login")."\">";
echo "<br />";
echo "<br />";
echo i18n("If you have lost or forgotten your <b>password</b>, pleaes <a href=\"register_judges.php?action=resend\">click here to resend</a> it to your email address");
}
else
{
echo i18n("Please choose a password in order to create your judges account");
echo "<br />";
echo "<br />";
echo "<input type=\"hidden\" name=\"action\" value=\"new\">";
echo "<table>";
echo "<tr><td>";
echo i18n("Enter Password:");
echo "</td><td>";
echo "<input type=\"password\" size=\"10\" name=\"pass1\">";
echo "</td></tr>";
echo "<tr><td>";
echo i18n("Confirm Password:");
echo "</td><td>";
echo "<input type=\"password\" size=\"10\" name=\"pass2\">";
echo "</td></tr>";
echo "</table>";
echo "<br />";
echo "<input type=\"submit\" value=\"".i18n("Create Account")."\">";
}
echo "</form>";
}
else
{
echo i18n("Please enter your email address to :");
echo "<ul>";
echo "<li>".i18n("Begin a new registration")."</li>";
echo "<li>".i18n("Login to your account")."</li>";
echo "</ul>";
?>
<form method="post" action="register_judges.php">
<input type="hidden" name="action" value="login" />
<?=i18n("Email")?>: <input type="text" name="email" size="30" />
<input type="submit" value="Begin" />
</form>
<?
}
send_footer();
?>