View Full Version : Using Buttons to open pages

06-03-2009, 07:04 PM
I have a login page whih contains the code shown below. What I want is that if the $message is called (because the user is not registered) I want a submit button click to refer the user back to the registration page. How do I do this please:

<!DOCTYPE html PUBLIC "\//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml">
<title> </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!--Design copyright 2008 F. Coulter of Inspiration Web Design www.iswebdesign.co.uk-->
<meta http-equiv="Content-Script-Type" Content="text/javascript">
<meta name="keywords" content="">
<meta name="description" content= "">
<!-- template by www.iswebdesign.co.uk-->
<!-- Last updated -->
<link rel="stylesheet" href="css/pagestyle/default.css">
<link rel="stylesheet" href="css/pagestyle/lowres.css">
<script type="text/javascript" language="javascript">
if (screen.availWidth > 820)
document.writeln('<link rel="stylesheet" type="text/css" href="css/pagestyle/medres.css">');
if (screen.availWidth > 1150)
document.writeln('<link rel="stylesheet" type="text/css" href="css/pagestyle/highres.css">');
var marginTop = (screen.availHeight - 840)/2;
if ( marginTop < 10 ){ marginTop = 10; }
document.writeln('<style type="text/css">#maindiv{margin-top:' + marginTop + 'px;}</style>');

// -->
<script language="JavaScript" type="text/javascript" src="flashscript/flashvars.js"></script>
<script language="VBScript" type="text/vbscript" src="flashscript/flashver.vbs"></script>
<script language="JavaScript1.1" type="text/javascript" src="flashscript/detectflash.js"></script>
<script language="JavaScript1.1" type="text/javascript" src="flashscript/embedflash.js"></script>

<style type="text/css">
<!--additional page styles here-->
<div id="maindiv">
<div id="crossbar"><!-- this is the banner image-->
<div id="message">
<!-- DO NOT EDIT between here-->

$u = $_POST['username'];
$p = $_POST['password'];

if($u && $p){

$query = mysql_query("SELECT * FROM tbl_register WHERE username = '$u' AND password = '$p'");

$result = mysql_fetch_array($query);


$_SESSION['doorman'] = $result['username'];



$message = "We are sorry but you do not appear to be registered yet. _
To access our free downloads please register";




<!-- and here-->
<br style="clear:both" />
<div id="contactbar">
<div id="contacttext"><!-- this is where contact or other information goes
to be displayed in strip across page below banner-->
<div id="menubar">
<!-- this is the bar at the side-->
<br id="pagebreak" />
<div id="scrollbox">
<!-- this is where main content begins - can add text or pictures-->
<p>To access our free downloads please Login here:</p>
if ($message) {
echo 'We are sorry but you do not appear to be registered yet. To access our free downloads please register'; }
<form name="form1" id="form1" method="post" action="">
<table width="237" border="0">
<th scope="col"><div align="right"></div></th>
<th scope="col">&nbsp;</th>
<th scope="row"><div align="right">Username:</div></th>
<td><input name="username" type="text" id="username" size="20" /></td>
<th scope="row"><div align="right">Password:</div></th>
<td><input name="password" type="text" id="password" size="20" /></td>
<th scope="row"><div align="right"></div></th>
<td><input type="submit" name="Submit" value="Submit" /></td>

<br style="clear:both"/>
<div style="display:none;">Template by <a href="http://www.iswebdesign.co.uk">Inspiration</a> Available from <a href="http://www.spiraltemplates.co.uk">Spiral Templates</a></div>



06-04-2009, 05:31 PM
first off this is PHP and not ASP. second the best way to do this is to check if your 'doorman' session variable is true or false and redirect that way.

06-04-2009, 05:59 PM
thread moved.

06-04-2009, 09:37 PM
also your using $_SESSIONS but don't see a session_start()

06-04-2009, 09:45 PM
where you have this...



session_start(); /// << add this here

also where you have this...


if ($message) {

echo 'We are sorry but you do not appear to be registered yet. To access our free downloads please register'; }

instead of echoing the string "We are sorry but....." just echo $message