Jump to content

help with sign up page


prakash911

Recommended Posts

this is my sign up page code:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<?php

require('db_connect.php');

$database = "bookstore";

$db_link = db_connect($database);

date_default_timezone_set('America/New_York');

display_signup_page();

?>

<?php

function display_signup_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">

<link href="reset.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.html" title="Search">Search</a></li>

      <li><a href="forum.html" title="Forum">Forums</a></li>

      <li><a href="login.html" title="Contact">Login</a></li>

      <li class="end">                                                                                                               

      <a href="signup.html" 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></td></tr>

<tr ><td > <font face='Verdana' size='2' >User ID</td><td ><font face='Verdana' size='2'><input type="text" name="userid"></td></tr>

 

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

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

 

 

<tr bgcolor='#f1f1f1'><td style="height: 21px" ><font face='Verdana' size='2' > Email<br>

([email protected])</td><td style="height: 21px"  ><input type='text' name='email'></td></tr>

<tr ><td > <font face='Verdana' size='2' >First Name</td><td ><font face='Verdana' size='2'><input type="text" name="firstname"></td></tr>

<tr ><td > <font face='Verdana' size='2' >Last Name</td><td ><font face='Verdana' size='2'><input type="text" name="lastname"></td></tr>

 

<tr bgcolor='#f1f1f1'><td > <font face='Verdana' size='2' >Sex</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</td></tr>

 

<tr ><td > <font face='Verdana' size='2' >I agree to terms and conditions</td>

<td >     Yes<input name="agree" type="checkbox" value="yes" />No<input name="agree" type="checkbox" value="no" /></td></tr>

 

</table>

<p class="style2"> <input name="signup" type="submit" value="signup"/></p>

</div>

</div>

    <div id="footer">

    <p> SC Books  •  Est.2010</p>

  </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">

<link href="reset.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.html" title="Search">Search</a></li>

      <li class="end"><a href="forum.html" 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.html">Click here to login</p></li>

</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'] : '';

 

 

 

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:[email protected])<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";

    }

    if($errors == 0)

    {

    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_quert($query2,$db_link);

echo "<br/><h1>Welcome,\n You have successfully signed up\n<br/><br/>\n<a href=login.html>Click here to login</a><br/>\n";

}

}

?>

 

 

when i click the sign up page  i am getting this:

error1.png

 

 

possibly something is not right, but i traced my code over and over again and cant figure out, please help me find the problem and fix it. i am fairly new to php.

Link to comment
https://forums.phpfreaks.com/topic/195349-help-with-sign-up-page/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.