Jump to content


Photo

If command


  • Please log in to reply
6 replies to this topic

#1 cdtc

cdtc
  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 26 June 2006 - 03:16 PM

Hi, I am having problems with a small section off my code. There are no errors with the code, it is just not doing what I want it to do. This is what I have at the moment:

<?php
$db=mssql_connect("blah","blah","blah") or die("Cannot connect to database server");
mssql_select_db("blah",$db);
$strSQL="SELECT * FROM School WHERE ([School Code Number] = '" .$_POST['schoolcode']."')";
$result=mssql_query($strSQL);
if (is_resource($rsData)) {
password2.php;
}
else
{
incorrect.html;
}
?>

bassicly if it finds a schoolcode it will go to password2.php, if there is no school code that matches then it will go to incorrect.html

Thanks in advance

Sam (CDTC)


CDTC (Cool Digital Technology)
www.cdtc.co.uk

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 26 June 2006 - 03:27 PM

And your problem is?

#3 cdtc

cdtc
  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 26 June 2006 - 03:31 PM

[!--quoteo(post=388087:date=Jun 26 2006, 10:27 AM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Jun 26 2006, 10:27 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
And your problem is?
[/quote]

The page stays on nopassword.php (which is blank) and does not go to any page
CDTC (Cool Digital Technology)
www.cdtc.co.uk

#4 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 26 June 2006 - 03:36 PM

You need to do:

<?php
$db=mssql_connect("blah","blah","blah") or die("Cannot connect to database server");
mssql_select_db("blah",$db);
$strSQL="SELECT * FROM School WHERE ([School Code Number] = '" .$_POST['schoolcode']."')"; 
$result=mssql_query($strSQL);
if (is_resource($rsData)) {
header("Location: password2.php"); exit;
}
else
{
header("Location: incorrect.html"); exit;
};
?>

Orio.
Think you're smarty?

(Gone until 20 to November)

#5 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 26 June 2006 - 03:37 PM

if (is_resource($rsData)) {
    echo "<meta http-equiv='refresh' content='0;url=password2.php'>";
} else {
    echo "<meta http-equiv='refresh' content='0;url=incorrect.html'>";
}
EDIT: Beaten to it!

#6 cdtc

cdtc
  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 26 June 2006 - 03:46 PM

[!--quoteo(post=388094:date=Jun 26 2006, 10:37 AM:name=SemiApocalyptic)--][div class=\'quotetop\']QUOTE(SemiApocalyptic @ Jun 26 2006, 10:37 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
if (is_resource($rsData)) {
    echo "<meta http-equiv='refresh' content='0;url=password2.php'>";
} else {
    echo "<meta http-equiv='refresh' content='0;url=incorrect.html'>";
}
EDIT: Beaten to it!
[/quote]

Thats great thanks!!
CDTC (Cool Digital Technology)
www.cdtc.co.uk

#7 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 26 June 2006 - 03:54 PM

But it's more recomended to use serverside redirects, mainly because they are faster and because some browser dont support meta refresh.

W3C states in [a href=\"http://www.w3schools.com/html/html_meta.asp\" target=\"_blank\"]this page[/a]:
Note: W3C states that "Some user agents support the use of META to refresh the current page after a specified number of seconds, with the option of replacing it by a different URI. Authors should not use this technique to forward users to different pages, as this makes the page inaccessible to some users. Instead, automatic page forwarding should be done using server-side redirects"


Orio.
Think you're smarty?

(Gone until 20 to November)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users