Jump to content

help with page redirecting, i am too dumb


prakash911

Recommended Posts

my code works perfect, but the only problem is after submit the output page is displayed underneath the main page, i want it to be redirected into a new web page instead of underneath it how do i do this.

 

here is my code i think the problem is how i setted up my if statements can someone tell me where i went wrong?

 

<?php
require('db_connect.php');
$database = "chennupatidb";
$db_link = db_connect($database);
?>
<?php
function display_signup_page()
{
$self = $_SERVER['PHP_SELF'];
?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<link href="books.css" rel="stylesheet" type="text/css">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Sign Up</title>

<script type="text/javascript"> 
function validate(table) { 
if (!document.table.agree.checked){ 
alert("Please Read the guidlines and check the box below  ."); 
	return false; 
} 
return true;
}
</script>

<style type="text/css">
.style1 {
font-size: medium;
}
.style2 {
margin-left: 240px;
}
</style>
</head>
<body>
<div id="pageWrap">
  <div id="header">
  </div>
  <div id="navBar">
    <ul>
      <li><a href="Bookstore.php" title="Homw">Home</a></li>
      <li><a href="search.php" title="Search">Search</a></li>
      <li><a href="forum.php" title="Forum">Forums</a></li>
      <li><a href="login.php" title="Contact">Login</a></li>
      <li class="end">                                                                                                                
      <a href="signup.php" title="signup">Sign Up</a></li>
      <li></li>
    </ul>
  </div>
<div id="container" class="clearfix">
    <div id="centerColumn">
    
<h2>Create an Account</h2>
<p><font size="-1">If you already have a SC Bookstore Account, you can
<a href="login.html">
login in here</a>.</font></p>
<p class="style1"><strong>Required information</strong></p>

<table border='0' width='50%' cellspacing='0' cellpadding='0' align="center">
<form method="post" action="<?php echo $self ?>" onsubmit='return validate(this)'>
<input type="hidden" name="table" value="post">

<tr bgcolor='#f1f1f1'><td align="center" colspan=2><font face='Verdana' size='2' ><b>Signup</b></font></td></tr>
<tr ><td > <font face='Verdana' size='2' >User ID</font></td><td ><font face='Verdana' size='2'></font><input type="text" name="userid"></td></tr>

<tr bgcolor='#f1f1f1'><td > <font face='Verdana' size='2' >Password</font></td><td ><font face='Verdana' size='2'><input type='password' name="password"></font></td></tr>
<tr ><td > <font face='Verdana' size='2' >Re-enter Password</font></td><td ><font face='Verdana' size='2'><input type='password' name="password2"></font></td></tr>


<tr bgcolor='#f1f1f1'><td style="height: 21px" ><font face='Verdana' size='2' > Email<br>
(abcd123@hotmail.com)</font></td><td style="height: 21px"  ><input type='text' name='email'></td></tr>
<tr ><td > <font face='Verdana' size='2' >First Name</font></td><td ><font face='Verdana' size='2'><input type="text" name="firstname"></font></td></tr>
<tr ><td > <font face='Verdana' size='2' >Last Name</font></td><td ><font face='Verdana' size='2'><input type="text" name="lastname"></font></td></tr>

<tr bgcolor='#f1f1f1'><td > <font face='Verdana' size='2' >Sex</font></td><td ><font face='Verdana' size='2'>  <input type='radio' value="male" checked="checked" name="sex">Male <input type='radio' value="female"  name='sex'>Female</font></td></tr>

<tr ><td > <font face='Verdana' size='2' >I agree to terms and conditions</font></td>
<td >     Yes<input name="agree" type="checkbox" value="yes">No<input name="agree" type="checkbox" value="no"></td></tr>
<p class="style2"> <input name="signup" type="submit" value="signup"></p>
</form>
</table>
</div>
</div>
    <div id="footer">
    <p> SC Books  â€¢  Est.2010</p>
  </div>
  </div>
</body>
</html>
<?php
}
?>

<?php
function display_signup_output_page()
{
?>

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">

<head>
<link href="books.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>SC BookStore</title>
</head>
<body>
<div id="pageWrap">
  <div id="header">
  </div>
  <div id="navBar">
    <ul>
      <li><a href="Bookstore.php" title="Homw">Home</a></li>
      <li><a href="search.php" title="Search">Search</a></li>
      <li class="end"><a href="forum.php" title="Forum">Forums</a></li>
        <li></li>
    </ul>
  </div>
<div id="container" class="clearfix">
    <div id="centerColumn">
    
	<h2>
	Thank You For Signing Up!</h2>
	<p>
	 </p>
	<h3>You Can Login here </h3><p><a href="login.php">Click here to login</p>
	</div>
</div>
</div>
</body>
</html>
<?php
}
?>

<?php
   extract($_POST);
   $self = $_SERVER['PHP_SELF'];
   $user_id = isset($_REQUEST['userid']) ? $_REQUEST['userid'] : '';
   $first_name = isset($_REQUEST['firstname']) ? $_REQUEST['firstname'] : '';
   $last_name = isset($_REQUEST['lastname']) ? $_REQUEST['lastname'] : '';
   $password_one = isset($_REQUEST['password']) ? $_REQUEST['password'] : '';
   $password_two = isset($_REQUEST['password2']) ? $_REQUEST['password2'] : '';
   $email = isset($_REQUEST['email']) ? $_REQUEST['email'] : '';
   $agree = isset($_REQUEST['agree']) ? $_REQUEST['agree'] : '';
   $signup = isset($_REQUEST['signup']) ? $_REQUEST['signup'] : '';
   $table = isset($_REQUEST['table']) ? $_REQUEST['table'] : '';

   display_signup_page();

if (isset($_REQUEST['signup']))
{
    $expression = "/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}$/";
    $errors = 0;

if(!isset($user_id) or strlen($user_id) < 5)
{
	echo "<br/>\nUser ID must be 5 letters or longer<br/>\n";
	$errors++;
}

if(!ctype_alnum($user_id))
{
	echo "<br/>\nUser id should contain alphanumeric values only<br/>\n";
	$errors++;
}

if(mysql_num_rows(mysql_query("SELECT userid FROM sign_up WHERE userid = '$userid'")))
{
	echo "<br/>\nThis User ID already exists. Please try another one<br/>\n";
	$errors++;
}

if (strlen($password_one) < 6 )
{
	echo "<br/>\nPassword must be more than 6 char legth<br/>\n";
	$errors++;
}					

if ($password_one <> $password_two)
{
	echo "<br/>\nPasswords are not matching<br/>\n";
	$errors++;
    }
    
    if(strlen($email) == 0)
{
  		echo "Please go back and check (ex:abcd123@hotmail.com)<br/>\n";
  		$errors++;
}


    if (! $agree == "yes")
{
  echo "<br/>\nYou must agree to terms and conditions<br\>\n";
  $errors++;
    }
    
    if($errors >= 1)
    {
    	echo "<br/>\n<input type='button' value='Retry' onClick='history.go(-1)'>\n";
    }
    else
    {
    	       display_signup_output_page();
	$query = "insert into sign_up(userid,password,email,firstname,lastname,sex) values('$userid','$password','$email','$firstname','$lastname','$sex')";
	$result = mysql_query($query,$db_link);
	$query2 = "insert into members(username,password,email) values('$userid','$password','$email')";
	$result2 = mysql_query($query2,$db_link);
	echo "<br/><h1>Welcome,\n You have successfully signed up\n</h1><br/><br/>\n<a href=login.php>Click here to login</a><br/>\n";
    }
}
?>

 

here is a picture of what i am getting, i dont want this.

signup.jpg

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.