tT Posted November 8, 2007 Share Posted November 8, 2007 pls help, when i load this page, nothing shows,, maybe there is something wrong with my code... here is my code: <?php session_start(); ob_start(); include "conn.inc.php"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Database</title> <style type="text/css"> <!-- .style6 {font-size: 9px; font-family: Verdana; } .style8 {font-size: 10px; font-family: Verdana; } --> </style> </head> <body> <?php if (isset($_POST['submit']) && $_POST['submit'] == "Register") { if($_POST['username'] != " " && $_POST['password'] != " " && $_POST['first_name'] != " " && $_POST['last_name'] != " " && $_POST['email'] != " "){ $_query = "SELECT username FROM user_info " . "WHERE username = '" . $_POST['username'] . "'; "; $result = mysql_query($query) or die(mysql_error()); if(mysql_num_rows($result) != 0) { ?> <p class="style8"> <font color="#FF0000"><b> The Username <?php echo $_POST['username']; ?>, is already in use, please choose another</b></font> <form action="register.php" method="post"> <table width="444" border="1" cellpadding="7" class="style6"> <tr> <td width="207" class="style6">Username: </td> <td width="197" class="style6"><input type="text" name="username3" /></td> </tr> <tr> <td class="style6">Password:</td> <td class="style6"><input type="password" name="password3" value="<?php echo $_POST['password']; ?>" /></td> </tr> <tr> <td class="style6">Email: </td> <td class="style6"><input type="text" name="email3" value="<?php echo $_POST['email']; ?>" /></td> </tr> <tr> <td class="style6">First Name:</td> <td class="style6"><input type="text" name="first_name3" value="<?php echo $_POST['first_name']; ?>" /></td> </tr> <tr> <td class="style6">Last Name</td> <td class="style6"><input type="text" name="last_name3" value="<?php echo $_POST['last_name']; ?>" /></td> </tr> <tr> <td class="style6">City:</td> <td class="style6"><input type="text" name="city3" value="<?php echo $_POST['city']; ?>" /></td> </tr> <tr> <td class="style6">State:</td> <td class="style6"><input type="text" name="state3" value="<?php echo $_POST['state']; ?>" /></td> </tr> <tr> <td class="style6"><input type="submit" name="submit3" value="Register" /></td> <td class="style6"><input name="reset2" type="reset" value="clear" /></td> </tr> </table> </form> </p> <?php }else{ $query "INSERT INTO user_info (username, password, email, " . "first_name, last_name, city, state) " . "VALUES ('" . $_POST['username'] . "', " . "PASSWORD('" . $_POST['password'] . "')) '" . $_POST['email'] . "', '" . $_POST['first_name'] ."', '" . $_POST['city'] . "', '" . $_POST['state'] . "');"; $result = mysql_query($query) or die(mysql_error()); $_SESSION['user_logged']= $_POST['username'] . " " . $_SESSION['user_password'] = $_POST['password']; ?> <p><span class="style8"> Thank You, <?php echo $_POST['first_name'] . " " . $_POST['last_name']; ?> for registering.</span><br /> <?php header ("Refresh: 5; URL=home.php"); echo "Youe registration is complete! " . "You are being sent to requested page<br>"; echo "(If your browser doesnt support this, " . "<a href=\"home.php\">click here</a>)"; die(); } }else{ ?> <p class="style8"> <font color="#FF00000"><b>The Username, Password, Email, First Name and Last Name fields are required</b></font> <form action="register.php" method="post"> <table width="445" border="1" cellpadding="7"> <tr> <td width="206" class="style6">Username:</td> <td width="199" class="style6"><input type="text" name="username2" value="<?php echo $_POST['username']; ?>" /></td> </tr> <tr> <td class="style6">Password:</td> <td class="style6"><input type="password" name="password2" value="<?php echo $_POST['password']; ?>" /></td> </tr> <tr> <td class="style6">Email: </td> <td class="style6"><input type="text" name="email2" value="<?php echo $_POST['email']; ?>" /></td> </tr> <tr> <td class="style6">First Name:</td> <td class="style6"><input type="text" name="first_name2" value="<?php echo $_POST['first_name']; ?>" /></td> </tr> <tr> <td class="style6">Last Name:</td> <td class="style6"><input type="text" name="last_name2" value="<?php echo $_POST['last_name'];?>" /></td> </tr> <tr> <td class="style6">City:</td> <td class="style6"><input type="text" name="city2" value="<?php echo $_POST['city'];?>" /></td> </tr> <tr> <td class="style6">State:</td> <td class="style6"><input type="text" name="state2" value="<?php echo $_POST['state'];?>" /></td> </tr> <tr> <td class="style6"><input type="submit" name="submit2" value="Register" /></td> <td class="style6"><input type="reset" name="Clear" /></td> </tr> </table> </form> </p> <?php } }else{ ?> <p class="style8"> Welcome to the registration page<br /> The Username, Password, Email, First Name and Last Name fields are required. <form action="register.php" method="post"> <table width="444" border="1" cellpadding="7"> <tr> <td width="207" class="style6">Username:</td> <td width="197"><input name="username" type="text" /></td> </tr> <tr> <td class="style6">Password: </td> <td><input name="password" type="password" /></td> </tr> <tr> <td class="style6">Email: </td> <td><input name="email" type="text" /></td> </tr> <tr> <td class="style6">First Name:</td> <td><input name="first_name" type="text" /></td> </tr> <tr> <td class="style6">Last Name:</td> <td><input name="last_name" type="text" /></td> </tr> <tr> <td class="style6">City: </td> <td><input name="city" type="text" /></td> </tr> <tr> <td class="style6">State: </td> <td><input name="state" type="text" /></td> </tr> <tr> <td><input name="submit" type="submit" value="Register" /></td> <td><input name="reset" type="reset" value="Clear" /></td> </tr> </table> </form> </p> <?php } ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
marcus Posted November 8, 2007 Share Posted November 8, 2007 Heh. You could easily simplify that to a much smaller page, and easier to work with. /* create a page form.php which can hold just the form itselfs use an array based error system */ if(!$_POST['submit']){ include "./form.php"; }else { # your variables $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); //etc... $errors = array(); if(!$username){ $errors[] = "You did not supply a username"; } if(!$password){ $errors[] = "You did not supply a password"; } #etc if(count($errors) > 0){ foreach($errors AS $error){ echo $error . "<br>\n"; } include "./form.php"; }else { # register } } Quote Link to comment Share on other sites More sharing options...
tT Posted November 8, 2007 Author Share Posted November 8, 2007 thanx, i'll give it a try Quote Link to comment Share on other sites More sharing options...
obsidian Posted November 8, 2007 Share Posted November 8, 2007 thanx, i'll give it a try In answer to your initial question, I believe it's because you turn on output buffering with your ob_start() call, but you never actually end or clean the OB. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.