You are here: NEWBIE to php « PHP SQL « IT news, forums, messages
NEWBIE to php

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация