hasek522 Posted July 24, 2008 Share Posted July 24, 2008 I am having a problem with the HTML and PHP on my Sign Up page at this project website im making. Every time you have a successful account creation it takes you just to a blank page. I think it might be a problem with how many if statements are set up but then again im not sure. If some one could take a look and help me out I would really appreciate it. Here is the code: <?php require("config.php"); $db = mysql_connect($dbhost, $dbuser, $dbpassword); mysql_select_db($dbdatabase, $db); $successBool = false; // if($_POST['submit']) { if($_POST['password1'] == $_POST['password2']) { // Protect Against SQL injections $password = addslashes(htmlentities($_POST['password1'])); $username = addslashes(htmlentities($_POST['username'])); $email = addslashes(htmlentities($_POST['email'])); $checksql = "SELECT * FROM users WHERE username = '" . $username . "';"; $checkresult = mysql_query($checksql); $checknumrows = mysql_num_rows($checkresult); //is the username taken? if($checknumrows == 1) { header("Location: " . $config_basedir . "Register.php?error=taken"); } else if(strlen($password) < 4 || strlen($password) > 10){ //password not the right length header("Location: " . $config_basedir . "Register.php?error=passlength"); } else if(strlen($_POST['username']) < 3 || strlen($_POST['username']) > 12){ //username not the right length header("Location: " . $config_basedir . "Register.php?error=namelength"); } else if(strpos($_POST['email'], '@') == false || strpos($_POST['email'], '.') == false){ // invalid email address header("Location: " . $config_basedir . "Register.php?error=email"); } //all good else { // Encode password for protection //$password = md5("[HEPA7][".$password."][".addslashes($verifystring)."][PROTECTED]"); $sql = "INSERT INTO users (username, password, email) VALUES( '" . $username . "', '" . $password . "', '" . $email . "')"; mysql_query($sql); $successBool = true; //tell the user to check their email } } else { // passwords did not match - show the error header("Location: " . $config_basedir . "Register.php?error=pass"); //header("Location: http://www.marek.litomisky.com"); } } else { //the submit button has not been clicked ?> <head> <meta name="author" content="Wink Hosting (www.winkhosting.com)" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="images/style.css" type="text/css" /> <title>Sign Up</title> </head> <body> <div id="page" align="center"> <div id="toppage" align="center"> <div id="date"> <div class="smalltext" style="padding:13px;"></div> </div> <div id="topbar"> <div align="right" style="padding:12px;" class="smallwhitetext"> <a href="index.php">Home</a> | <?php if(IsLoggedIn()) { echo '<a href="logout.php">Logout</a>'; } else { echo '<a href="login.php">Login</a>'; } ?> | <a href="Register.php">Sign Up</a> | <a href="contact.php">Contact Us</a></div> </div> </div> <div id="header" align="center"> <div class="titletext" id="logo"> <div class="logotext" style="margin:30px">My$</div> </div> <div id="pagetitle"> <div id="title" class="titletext" align="right">Welcome to MyMoney!</div> </div> </div> <div id="content" align="center"> <div id="menu" align="right"> <div align="right" style="width:189px; height:8px;"><img src="images/mnu_topshadow.gif" width="189" height="8" alt="mnutopshadow" /></div> <div id="linksmenu" align="center"> <a href="index.php" title="Home">Home</a> <a href="#" title="About Us">About Us</a> <a href="#" title="Products">Products</a> <a href="#" title="Our Services">Our Services</a> <a href="contact.php" title="Contact Us">Contact Us</a> </div> <div align="right" style="width:189px; height:8px;"><img src="images/mnu_bottomshadow.gif" width="189" height="8" alt="mnubottomshadow" /></div> </div> <div id="contenttext"> <div class="bodytext" style="padding:12px;" align="justify"> <p><strong class="orangetitle">Create An Account</strong><br /> <br /> Create an account to start enjoying the features of MyMoney!</p> <?php echo "<font color=red><b>"; switch($_GET['error']) { case "pass": echo "Passwords do not match!"; break; case "taken": echo "Username taken, please use a different one."; break; case "no": echo "Incorrect login details!"; break; case "passlength": echo "Please make sure your password has the specified length."; break; case "namelength": echo "Please make sure your username has the specified length."; break; case "email": echo "Invalid email address."; break; } echo "</font></b>"; if($successBool) { echo "<center>Your account has succefully been created!</center>"; } else { ?> <form action="Register.php" method="POST"> <table> <tr> <td>Username</td> <td><input type="text" name="username"></td> <td>3 to 12 characters; letters, numbers, and underscore only</td> </tr> <tr> <td>Password</td> <td><input type="password" name="password1"></td> <td>4 to 10 characters; letters & numbers only</td> </tr> <tr> <td>Password (again)</td> <td><input type="password" name="password2"></td> <td>4 to 10 characters; letters & numbers only</td> </tr> <tr> <td>Email</td> <td><input type="text" name="email"></td> <td></td> </tr> <tr> <td></td> <td><input type="submit" name="submit" value="Register!"></td> </tr> </table> </form> <?php } ?> <p> </p> </div> </div> </div> <div id="footer" class="smallgraytext" align="center"> <a href="#">Home</a> | <a href="#">About Us</a> | <a href="#">Products</a> | <a href="#">Our Services</a> | <a href="#">Contact Us</a><br /> Your Company Name © 2007<br /> <a href="http://www.winkhosting.com" title="Hosting Colombia">Hosting Colombia</a><br /> </div> </div> </body> </html> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/116504-php-and-html/ Share on other sites More sharing options...
blueman378 Posted July 25, 2008 Share Posted July 25, 2008 please use code [ code ][ /code ] tags: <?php require("config.php"); $db = mysql_connect($dbhost, $dbuser, $dbpassword); mysql_select_db($dbdatabase, $db); $successBool = false; // if($_POST['submit']) { if($_POST['password1'] == $_POST['password2']) { // Protect Against SQL injections $password = addslashes(htmlentities($_POST['password1'])); $username = addslashes(htmlentities($_POST['username'])); $email = addslashes(htmlentities($_POST['email'])); $checksql = "SELECT * FROM users WHERE username = '" . $username . "';"; $checkresult = mysql_query($checksql); $checknumrows = mysql_num_rows($checkresult); //is the username taken? if($checknumrows == 1) { header("Location: " . $config_basedir . "Register.php?error=taken"); } else if(strlen($password) < 4 || strlen($password) > 10){ //password not the right length header("Location: " . $config_basedir . "Register.php?error=passlength"); } else if(strlen($_POST['username']) < 3 || strlen($_POST['username']) > 12){ //username not the right length header("Location: " . $config_basedir . "Register.php?error=namelength"); } else if(strpos($_POST['email'], '@') == false || strpos($_POST['email'], '.') == false){ // invalid email address header("Location: " . $config_basedir . "Register.php?error=email"); } //all good else { // Encode password for protection //$password = md5("[HEPA7][".$password."][".addslashes($verifystring)."][PROTECTED]"); $sql = "INSERT INTO users (username, password, email) VALUES( '" . $username . "', '" . $password . "', '" . $email . "')"; mysql_query($sql); $successBool = true; //tell the user to check their email } } else { // passwords did not match - show the error header("Location: " . $config_basedir . "Register.php?error=pass"); //header("Location: http://www.marek.litomisky.com"); } } else { //the submit button has not been clicked ?> <head> <meta name="author" content="Wink Hosting (www.winkhosting.com)" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="images/style.css" type="text/css" /> <title>Sign Up</title> </head> <body> <div id="page" align="center"> <div id="toppage" align="center"> <div id="date"> <div class="smalltext" style="padding:13px;"></div> </div> <div id="topbar"> <div align="right" style="padding:12px;" class="smallwhitetext"> <a href="index.php">Home[/url] | <?php if(IsLoggedIn()) { echo '<a href="logout.php">Logout</a>'; } else { echo '<a href="login.php">Login</a>'; } ?> | <a href="Register.php">Sign Up</a> | <a href="contact.php">Contact Us</a></div> </div> </div> <div id="header" align="center"> <div class="titletext" id="logo"> <div class="logotext" style="margin:30px">My$</div> </div> <div id="pagetitle"> <div id="title" class="titletext" align="right">Welcome to MyMoney!</div> </div> </div> <div id="content" align="center"> <div id="menu" align="right"> <div align="right" style="width:189px; height:8px;"><img src="images/mnu_topshadow.gif" width="189" height="8" alt="mnutopshadow" /></div> <div id="linksmenu" align="center"> <a href="index.php" title="Home">Home</a> <a href="#" title="About Us">About Us</a> <a href="#" title="Products">Products</a> <a href="#" title="Our Services">Our Services</a> <a href="contact.php" title="Contact Us">Contact Us</a> </div> <div align="right" style="width:189px; height:8px;"><img src="images/mnu_bottomshadow.gif" width="189" height="8" alt="mnubottomshadow" /></div> </div> <div id="contenttext"> <div class="bodytext" style="padding:12px;" align="justify"> <p><strong class="orangetitle">Create An Account</strong> Create an account to start enjoying the features of MyMoney!</p> <?php echo "<font color=red>"; switch($_GET['error']) { case "pass": echo "Passwords do not match!"; break; case "taken": echo "Username taken, please use a different one."; break; case "no": echo "Incorrect login details!"; break; case "passlength": echo "Please make sure your password has the specified length."; break; case "namelength": echo "Please make sure your username has the specified length."; break; case "email": echo "Invalid email address."; break; } echo "</font>"; if($successBool) { echo "<center>Your account has succefully been created!</center>"; } else { ?> <form action="Register.php" method="POST"> <table> <tr> <td>Username</td> <td><input type="text" name="username"></td> <td>3 to 12 characters; letters, numbers, and underscore only</td> </tr> <tr> <td>Password</td> <td><input type="password" name="password1"></td> <td>4 to 10 characters; letters & numbers only</td> </tr> <tr> <td>Password (again)</td> <td><input type="password" name="password2"></td> <td>4 to 10 characters; letters & numbers only</td> </tr> <tr> <td>Email</td> <td><input type="text" name="email"></td> <td></td> </tr> <tr> <td></td> <td><input type="submit" name="submit" value="Register!"></td> </tr> </table> </form> <?php } ?> <p> </p> </div> </div> </div> <div id="footer" class="smallgraytext" align="center"> <a href="#">Home</a> | <a href="#">About Us</a> | <a href="#">Products</a> | <a href="#">Our Services</a> | <a href="#">Contact Us</a> Your Company Name © 2007 Hosting Colombia </div> </div> </body> </html> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/116504-php-and-html/#findComment-599131 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.