prakash911 Posted March 13, 2010 Share Posted March 13, 2010 hey guys this is my code below i am having some trouble with executing my php code. the php is suppose to validate the form and if no errors are found it should redirect the user into another web page saying successfully signed up. but the problem is nothing happens when i click the sign up button please help. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?php require('congfig.php'); 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.htm" 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="button" 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'] : ''; //$db_link = db_connect("bookstore"); 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"; } else { display_signup_output_page(); $query = mysql_query("insert into sign_up(userid,password,email,firstname,lastname,sex) values('$userid','$password','$email','$firstname','$lastname','$sex')"); 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"; } } ?> [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/195138-disperate-need-of-helpphp-coding-and-web-expression-3/ Share on other sites More sharing options...
Instigate Posted March 13, 2010 Share Posted March 13, 2010 On this line: <p class="style2"> <input name="signup" type="button" value="Signup" /> Change it to: <p class="style2"> <input name="signup" type="submit" value="submit" name="Signup" /> I haven't read through all your code but that's the most obvious thing I can see. Link to comment https://forums.phpfreaks.com/topic/195138-disperate-need-of-helpphp-coding-and-web-expression-3/#findComment-1025723 Share on other sites More sharing options...
prakash911 Posted March 13, 2010 Author Share Posted March 13, 2010 ugg of course, thank you so much its so hard to find errors when the code is so massive. Link to comment https://forums.phpfreaks.com/topic/195138-disperate-need-of-helpphp-coding-and-web-expression-3/#findComment-1025727 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.