PDA

View Full Version : Using Buttons to open pages


Beeky
06-03-2009, 08: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"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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>
<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-->
</style>
</head>
<body>
<div id="maindiv">
<div id="crossbar"><!-- this is the banner image-->
<div id="message">
<!-- DO NOT EDIT between here-->
<?php
include("includes/addlogo.php");
include("connection_register.php");
////////////////////////////////////////
////////////////////////////////////////

$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);

if($result['username']){

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

header("location:Downloads.php");
exit;

}else{

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

}


}


?>


<!-- and here-->
</div>
</div>
<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>
</div>
<div id="menubar">
<!-- this is the bar at the side-->
</div>
<br id="pagebreak" />
<div id="scrollbox">
<!-- this is where main content begins - can add text or pictures-->
<h3>Heading</h3>
<p>To access our free downloads please Login here:</p>
<?php
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">
<tr>
<th scope="col"><div align="right"></div></th>
<th scope="col">&nbsp;</th>
</tr>
<tr>
<th scope="row"><div align="right">Username:</div></th>
<td><input name="username" type="text" id="username" size="20" /></td>
</tr>
<tr>
<th scope="row"><div align="right">Password:</div></th>
<td><input name="password" type="text" id="password" size="20" /></td>
</tr>
<tr>
<th scope="row"><div align="right"></div></th>
<td><input type="submit" name="Submit" value="Submit" /></td>
</tr>
</table>
</form>


<p></p>
</div>
<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>

</div>

</body>
</html

rico1931
06-04-2009, 06: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.

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

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

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


<?php

include("includes/addlogo.php");
include("connection_register.php");

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

also where you have this...



<?php

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