I was thinking about why my variables weren't working and it has to do with the $POST variable from the info check form. Once the user presses the submit button on the info edit page, it will reload itself, and since the $POST['change variable was no longer set, it would just reload the forms or come up with a blank page becuase nothing had set to true. So I was brainstorming and I can't believe I thought of it before, but it made it work. I figured since the $POST['change'] variable wasn't set whenever the $SERVER[php_self'] was called, i put a hidden input in the form on the info edit page, so when the page did reload, it would be resubmitting the $_POST['change'] with the appropriate value so the page would always show it being set. PROBLEM SOLVED!!!! THANKS TO EVERYONE WHO HELPED OUT!!!!!!! Explanation below......
<?
session_start();
if (isset($_SESSION['login'])){
header('location:loginchoice.php');
}
if (isset($_COOKIE['login'])){
header('location:loginchoice.php');
}
if (!isset($_SESSION['email'], $_SESSION['secCode2'], $_SESSION['terms'], $_SESSION['bandname'], $_SESSION['bio'])){
header('location:bandusersignup.php');
}
/*Value email would always detect on submission from the previous form page, but once the page reloaded, a new set of $_POST values would be set, and $_POST['change'] would become false, therfore wiping out my entire email section. */
if ($_POST['change'] =="email") {
if (isset($_POST['changeemail'])){
if ($_POST['changeemail'] =="") {
$error=true;
}
$_POST['changeemail'] = $changeemail;
function check_email_address($changeemail) {
if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $changeemail)) {
return false; }
$changeemail_array = explode("@", $changeemail);
$local_array = explode(".", $changeemail_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++) {
if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
return false;
}
}
if (!ereg("^\[?[0-9\.]+\]?$", $changeemail_array[1])) {
$domain_array = explode(".", $changeemail_array[1]);
if (sizeof($domain_array) < 2) {
return false;
}
for ($i = 0; $i < sizeof($domain_array); $i++) {
if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
return false;
}
}
}
return true;
}
if (!$error){
if (!check_email_address($changeemail)){
$error4=true;
}
}
if($_POST['changeemail'] !=="" and !$error4){
$_POST['changeemail'] = $changeemail;
mysql_connect("******" , "******" , "*******")
or die('Database is not responding.');
mysql_select_db("crescen9_Bandusers") or die('Unable to connect to database');
$match="SELECT * FROM Userinfo WHERE email = '$changeemail'";
$qry = mysql_query($match)
or die('Could not match data because of database error' . mysql_error());;
$num_rows = mysql_num_rows($qry);
if (!$num_rows <= 0) {
$error3=true;
}
}
if ($error !=true and $error3 != true and $error4 != true){
$_SESSION['email'] = $_POST['changeemail'];
unset($changeemail);
header('location:infocheck.php');
}
}
if ($error){
echo"<center><span style=\"color:red\"><font size=\"2\" face=\"verdana\">Some required information was blank or didn't match. Try Again.</font></span></center><br>";
}
if ($error3) {
echo"<center><span style=\"color:red\"><font size=\"2\" face=\"verdana\">That email already exists. Please enter another.</font></span></center><br>";
}
if ($error4) {
echo"<center><span style=\"color:red\"><font size=\"2\" face=\"verdana\">Invalid email format. Please Try Again. </font></span></center>";
}
echo"<body bgcolor=\"#888888\"><center><font size=\"3\" face=\"verdana\">CHANGE YOUR EMAIL ADDRESS</font><br><br>
<table width=\"#500\" bgcolor=\"#EEEEEE\"><tr><td align=\"left\" valign=\"top\"><font size=\"2\" face=\"verdana\"><form method=\"post\" action=\"".$_SERVER['PHP_SELF']."\">Email:</td><td align=\"center\"><input type=\"text\" size=\"30\" name=\"changeemail\">
/*So I inserted a hidden variable that is the same as the previous submission form, so that when the page reloads itself, $_POST['change'] would always set true. Each area ie. email, password has it's own unique values. */
<input type=\"hidden\" name=\"change\" value=\"email\"></td></tr><tr><td align=\"left\"><input type=\"image\" src=\"images/submitbutton.jpg\" name=\"editemail\"></form></font></tr></table></body>";
}
if ($_POST['change'] == "password") {
if (isset($_POST['changepassword'])){
if ($_POST['changepassword'] =="") {
$error=true;
}
if ($_POST['changepassword'] !== $_POST['confirmnewpassword']){
$error2=true;
}
if ($error !=true and $error2 != true){
$_SESSION['password'] = $_POST['changepassword'];
header('location:infocheck.php');
}
}
if ($error){
echo"<center><span style=\"color:red\"><font size=\"2\" face=\"verdana\">Some required information was blank or didn't match. Try Again.</font></span></center><br>";
}
if ($error2) {
echo"<center><span style=\"color:red\"><font size=\"2\" face=\"verdana\">Your passwords did not match. Please try again.</font></span></center><br>";
}
echo"<body bgcolor=\"#888888\"><center><font size=\"3\" face=\"verdana\">CHANGE YOUR PASSWORD</font><br><br>
<table width=\"#500\" bgcolor=\"#EEEEEE\"><tr><td align=\"left\" valign=\"top\"><font size=\"2\" face=\"verdana\"><form method=\"post\" action=\"".$_SERVER['PHP_SELF']."\">Password:</font></td><td align=\"center\"><input type=\"password\" size=\"30\" name=\"changepassword\"></td></tr><tr><td align=\"left\"></td></tr><tr><td align=\"left\" valign=\"top\"><font size=\"2\" face=\"verdana\">Confirm Password:</td><td align=\"center\" valign=\"top\"><input type=\"password\" size=\"30\" name=\"confirmnewpassword\">
/*Same thing here.....*/
<input type=\"hidden\" name=\"change\" value=\"password\"></td></tr><tr><td align=\"center\"><input type=\"image\" src=\"images\submitbutton.jpg\" name=\"editpassword\"></form></font></tr></table></body>";
}
?>