Jump to content

Archived

This topic is now archived and is closed to further replies.

cdtc

If command

Recommended Posts

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)

Share this post


Link to post
Share on other sites
And your problem is?

Share this post


Link to post
Share on other sites
[!--quoteo(post=388087:date=Jun 26 2006, 10:27 AM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Jun 26 2006, 10:27 AM) [snapback]388087[/snapback][/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

Share this post


Link to post
Share on other sites
You need to do:

[code]<?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;
};
?>[/code]

Orio.

Share this post


Link to post
Share on other sites
[code]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'>";
}[/code]
[b]EDIT:[/b] Beaten to it!

Share this post


Link to post
Share on other sites
[!--quoteo(post=388094:date=Jun 26 2006, 10:37 AM:name=SemiApocalyptic)--][div class=\'quotetop\']QUOTE(SemiApocalyptic @ Jun 26 2006, 10:37 AM) [snapback]388094[/snapback][/div][div class=\'quotemain\'][!--quotec--]
[code]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'>";
}[/code]
[b]EDIT:[/b] Beaten to it!
[/quote]

Thats great thanks!!

Share this post


Link to post
Share on other sites
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]:
[i]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"[/i]


Orio.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.