Notice: Undefined index: userID in c:\Inetpub\wwwroot\356\vmicchia\Project1\createNewAccount.php on line 5
Notice: Undefined index: passwd in c:\Inetpub\wwwroot\356\vmicchia\Project1\createNewAccount.php on line 7
Notice: Undefined index: passwd2 in c:\Inetpub\wwwroot\356\vmicchia\Project1\createNewAccount.php on line 8
Notice: Undefined index: userID in c:\Inetpub\wwwroot\356\vmicchia\Project1\createNewAccount.php on line 9
Here is the form that is being submitted:
<form method="post" id="form0" action="createNewAccount.php"> <ul> <li> <label for="login">User Name:</label> <input id="userID" name="userID" type="text" size="20" maxlength="20" /> </li> <li> <label for="pass">Password:</label> <input id="passwd" name="passwd" type="password" size="20" maxlength="20" /> </li> <li> <label for="pass2">Confirm Password:</label> <input id="passwd2" name="passwd2" type="password" size="20" maxlength="20" /> </li> <li> <input id="submit" name="submit" type="submit" value="Register" /> </li> <li><?php echo $_SESSION["errorMsg"]; ?></li> </ul>
and here is the pass through page it goes to:
<?php
//start the session
session_start();
$login = $_POST["userID"];
//echo $login;
$pass1 = md5($_POST["passwd"]);
$passConfirm = md5($_POST["passwd2"]);
$_SESSION["login"] = $_POST["userID"];
$passMatch = false;
if ((empty($_POST["login"])) || (empty($_POST["pass"])) || (empty($_POST["pass2"]))) /*|| (empty($_POST["lastName"])) || (empty($_POST["firstName"])) || (empty($_POST["email"])) || (empty($_POST["news"])))*/{
$_SESSION["errorMsg"] = "Please make sure to fill out all the fields.";
header("Location:index.php");
exit;
}
include("includes/openDbConn.php");
if ($pass1 == $passConfirm){
$sql="SELECT Login FROM employee WHERE Login='".$login."'";
//echo $sql;
$result=mysql_query($sql);
//nested if to check if the username is taken (if result)
if(empty($result)){
$num_results = 0;
}else{
$num_results = mysql_num_rows($result);
}//end if result
if ($num_resukts = 0){
$sql="INSERT INTO employees(Login, Passwd) VALUES ('".$login."', '".$pass1."')";
//echo $sql;
$result=mysql_query($sql);
$_SESSION["errorMsg"] ="You have been added successfully.";
$passMatch = true;
}else{
$_SESSION["errorMessage"] = "User Name already exists";
$passMatch = false;
}//end if taken
}else{
$_SESSION["errorMessage"] = "Your Passwords do not match.";
$passMatch =false;
}
if ($passMatch){
CleanUp();
header("Location:userHome.php");
exit;
}else{
CleanUp();
header("Location:createNewAccount.php");
exit;
}
//this function clears out all variables used on this page.
function CleanUp(){
$login="";
$pass1="";
$passConfirm="";
$passMatch="";
$sql="";
$result="";
$num_results="";
}
?>
any help would be really great thanks. I will be adding more elements later but this is just to test and make sure it works.
This post has been edited by Hirthas: 05 October 2009 - 10:40 AM

New Topic/Question
Reply




MultiQuote





|