|
Posted by vncntj on 10/14/74 11:35
I apologize for asking such an easy question but I'm trying to check if
the recordcount is "1". If so, it should redirect the page.
<?php
// Connecting, selecting database
$link=mysql_connect ("localhost", "user", "password") or die ('I cannot
connect to the database because: ' . mysql_error());
mysql_select_db ("dbData");
$slogin = trim($HTTP_POST_VARS["tlogin"]);
// Performing SQL query
$query = "SELECT Count(*) FROM tusernames WHERE logins = '$slogin'";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
if ($HTTP_POST_VARS["postback"]=="y") {
// Printing results in HTML
echo "<table>\n";
echo "\t<tr>\n";
echo "\t</tr>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
}
// This is where I'm having difficulty....
if ($col_value) == "1" {
header("www.espn.com"); /* Redirect browser */
/* Make sure that code below does not get executed when we redirect. */
exit;
}
// Free resultset
mysql_free_result($result);
// Closing connection
mysql_close($link);
?>
<form action="login.php" method="post">
<input type="hidden" name="postback" value="y">
<input name="tlogin" type="text" id="tlogin">
<br>
<input type="submit">
</form>
</body>
</html>
Navigation:
[Reply to this message]
|