Jump to content

If command


cdtc

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)

Link to comment
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
Link to comment
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.
Link to comment
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!
Link to comment
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!!
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.