cdtc Posted June 26, 2006 Share Posted June 26, 2006 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.htmlThanks in advanceSam (CDTC) Link to comment https://forums.phpfreaks.com/topic/12940-if-command/ Share on other sites More sharing options...
trq Posted June 26, 2006 Share Posted June 26, 2006 And your problem is? Link to comment https://forums.phpfreaks.com/topic/12940-if-command/#findComment-49690 Share on other sites More sharing options...
cdtc Posted June 26, 2006 Author Share Posted June 26, 2006 [!--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 https://forums.phpfreaks.com/topic/12940-if-command/#findComment-49694 Share on other sites More sharing options...
Orio Posted June 26, 2006 Share Posted June 26, 2006 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 https://forums.phpfreaks.com/topic/12940-if-command/#findComment-49696 Share on other sites More sharing options...
zq29 Posted June 26, 2006 Share Posted June 26, 2006 [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 https://forums.phpfreaks.com/topic/12940-if-command/#findComment-49697 Share on other sites More sharing options...
cdtc Posted June 26, 2006 Author Share Posted June 26, 2006 [!--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 https://forums.phpfreaks.com/topic/12940-if-command/#findComment-49701 Share on other sites More sharing options...
Orio Posted June 26, 2006 Share Posted June 26, 2006 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 https://forums.phpfreaks.com/topic/12940-if-command/#findComment-49703 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.