It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming PHP and MySQL Forum

if else header? I dunno. Help please =]

Moderator: Malcolm

if else header? I dunno. Help please =]

Postby Johnathan on Tue Feb 17, 2009 12:40 am

Hey, I got this

//Add Administrator
if (isset($_G.ET[admin])) {
$username=$_P.OST['username'];
$password=$_P.OST['password'];
$repeat_password=$_P.OST['repeat_password'];
$type=$_P.OST['type'];
if ($password == $repeat_password) {
$sql="INSERT INTO admin (username, password, type) VALUES ('$username','$password','$type')";
}else{
header("location:../add_administrator.php?password");
}
if (!mysql_query($sql,$con));
header("location:../administrators.php");
}

So I submit a form to add.php?admin it does stuff. It submits the stuff to the database ok. If the password is wrong it should go to ../administrators.php?password but it doesn't. It just goes to ../administrators.php I think it may have something to do with my if else.
Thanks in advance.
Johnathan
1000+ Club
 
Posts: 1207
Joined: Thu May 31, 2007 3:28 pm
Location: Belfast, Northen Ireland

Re: if else header? I dunno. Help please =]

Postby rangana on Tue Feb 17, 2009 3:02 am

Try to capitalize "L" in "location".

Should read: Location.

Also, I"m not sure if your PHP really works, your "get" param (admin) should be a string.

Anyway, see if the change helps.
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines

Re: if else header? I dunno. Help please =]

Postby Johnathan on Tue Feb 17, 2009 8:18 am

Got it fixed. Was tired last night :P Was nothing to do with the header, it was working without all that other crab there.

//Add Administrator
if (isset($_G.ET[admin])) {
$username=$_P.OST['username'];
$password=$_P.OST['password'];
$repeat_password=$_P.OST['repeat_password'];
$type=$_P.OST['type'];
if ($password == $repeat_password) {
$sql="INSERT INTO admin (username, password, type) VALUES ('$username','$password','$type')";
header("location:../administrators.php");
}else{
header("location:../add_administrator.php?password");
}
}

I dunno what I was doing with the redirect to admnistrator.php if it was ok lastnight but it all works now :)
Johnathan
1000+ Club
 
Posts: 1207
Joined: Thu May 31, 2007 3:28 pm
Location: Belfast, Northen Ireland


Who is online

Users browsing this forum: No registered users and 0 guests