unidox Posted October 24, 2007 Share Posted October 24, 2007 This is my code: // Variables $name = $_POST['name']; $dname = $_POST['display_name']; $username = $_POST['username']; $password = md5($_POST['password']); $email = $_POST['email']; $age = $_POST['age']; $dob = $_POST['dob']; $country = $_POST['country']; $location = $_POST['location']; $website = $_POST['website']; $aim = $_POST['aim']; $msn = $_POST['msn']; $yim = $_POST['yim']; $icq = $_POST['icq']; $info = $_POST['info']; $games = $_POST['games']; $interests = $_POST['interests']; // Query $q = mysql_query("SELECT * FROM `pcp_users` WHERE username = '$username' || email = '$email'"); $r = mysql_fetch_array($q); if(($r['username'] == $username) || ($r['email'] == $email)) { header("Location: " . $site_url . "index.php?p=register&e=1"); } if(($name == "") || ($dname == "") || ($username == "") || ($password == "") || ($email == "")) { header("Location: " . $site_url . "index.php?p=register&e=2"); } mysql_query("INSERT INTO `pcp_users` (username,password,email,display,name,description,age,dob,country,location,interest,website,aim,msn,icq,yim,games) VALUES ('$username','$password','$email','$dname','$name','$info','$age','$dob','$country','$location','$interests','$website','$aim','$msn','$icq','$yim','$games')") or die (mysql_error()); header("Location: " . $site_url . "index.php?p=login&e=4"); Now using that code, the header header("Location: " . $site_url . "index.php?p=login&e=4"); messes up the code, but if I comment that line out, then the code works fine. If I use it it forwards to " . $site_url . "index.php?p=login&e=4 when I am leaving form fields blank, but if I comment it out the, it corretly forwards it to " . $site_url . "index.php?p=register&e=2. Whats wrong? Thanks Link to comment https://forums.phpfreaks.com/topic/74650-solved-help/ Share on other sites More sharing options...
BlueSkyIS Posted October 24, 2007 Share Posted October 24, 2007 what is the error displayed? Link to comment https://forums.phpfreaks.com/topic/74650-solved-help/#findComment-377334 Share on other sites More sharing options...
steve448 Posted October 24, 2007 Share Posted October 24, 2007 use if / ifelse statements so it only executes the header you want. Something like: <?php if(($r['username'] == $username) || ($r['email'] == $email)) { header("Location: " . $site_url . "index.php?p=register&e=1"); } elseif(($name == "") || ($dname == "") || ($username == "") || ($password == "") || ($email == "")) { header("Location: " . $site_url . "index.php?p=register&e=2"); } else { mysql_query("INSERT INTO `pcp_users` (username,password,email,display,name,description,age,dob,country,location,interest,website,aim,msn,icq,yim,games) VALUES ('$username','$password','$email','$dname','$name','$info','$age','$dob','$country','$location','$interests','$website','$aim','$msn','$icq','$yim','$games')") or die (mysql_error()); header("Location: " . $site_url . "index.php?p=login&e=4"); } ?> Link to comment https://forums.phpfreaks.com/topic/74650-solved-help/#findComment-377336 Share on other sites More sharing options...
atlanta Posted October 24, 2007 Share Posted October 24, 2007 yea try above if doesnt work post the rest of the code with the site_url variable etc.. so we can see any other error that might cause it to not work Link to comment https://forums.phpfreaks.com/topic/74650-solved-help/#findComment-377338 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.